This commit is contained in:
boy0001 2015-02-20 15:32:40 +11:00
parent d836286b6f
commit d11679aa1e
3 changed files with 11 additions and 10 deletions

View File

@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
/**
@ -46,9 +47,8 @@ public class Database extends SubCommand {
}
public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) {
final Plugin p = PlotSquared.getMain();
final java.util.Set<Plot> plots = PlotSquared.getPlots();
p.getServer().getScheduler().runTaskAsynchronously(p, new Runnable() {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@ -94,7 +94,7 @@ public class Database extends SubCommand {
}
Connection n;
try {
n = new MySQL(PlotSquared.getMain(), host, port, database, username, password).openConnection();
n = new MySQL(PlotSquared.THIS, host, port, database, username, password).openConnection();
// Connection
if (n.isClosed()) {
return sendMessage(plr, "Failed to open connection");

View File

@ -49,6 +49,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
/**
@ -92,7 +93,7 @@ public class SQLManager implements AbstractDB {
// schedule reconnect
if (PlotSquared.getMySQL() != null) {
Bukkit.getScheduler().runTaskTimer(PlotSquared.getMain(), new Runnable() {
TaskManager.runTaskRepeat(new Runnable() {
@Override
public void run() {
try {
@ -101,7 +102,7 @@ public class SQLManager implements AbstractDB {
e.printStackTrace();
}
}
}, 11000, 11000);
}, 11000);
}
}
@ -1078,7 +1079,7 @@ public class SQLManager implements AbstractDB {
String comparison = below ? ">=" : "=";
if (plot != null) {
statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?");
statement.setInt(1, getId(plot.world.getName(), plot.id));
statement.setInt(1, getId(plot.world, plot.id));
statement.setInt(2, tier);
}
else {
@ -1284,7 +1285,7 @@ public class SQLManager implements AbstractDB {
public double getRatings(final Plot plot) {
try {
final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? ");
statement.setInt(1, getId(plot.world.getName(), plot.id));
statement.setInt(1, getId(plot.world, plot.id));
final ResultSet set = statement.executeQuery();
double rating = 0;
while (set.next()) {

View File

@ -59,15 +59,15 @@ public class SQLite extends Database {
if (checkConnection()) {
return this.connection;
}
if (!this.plotsquared.IMP.getDirectory().exists()) {
this.plugin.getDataFolder().mkdirs();
if (!PlotSquared.IMP.getDirectory().exists()) {
PlotSquared.IMP.getDirectory().mkdirs();
}
final File file = new File(this.dbLocation);
if (!(file.exists())) {
try {
file.createNewFile();
} catch (final IOException e) {
this.plugin.getLogger().log(Level.SEVERE, "Unable to create database!");
PlotSquared.log("&cUnable to create database!");
}
}
Class.forName("org.sqlite.JDBC");