diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 9eca4f450..d6f5e7c1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -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 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"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 21df6b43d..2dc454402 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -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()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 495f2999d..f18e60065 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -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");