From 2bbf5dba5d4f8214d59ae0634440b6534681fcd5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 15 May 2015 13:29:23 +1000 Subject: [PATCH] Fixes + options - Fixed plot deletion not removing denied from DB - Fixed help not displaying all pages correctly - Added option for plot expiry clear interval --- PlotSquared/pom.xml | 2 +- .../com/intellectualcrafters/plot/PlotSquared.java | 3 +++ .../plot/commands/MainCommand.java | 12 +++++++++--- .../intellectualcrafters/plot/config/Settings.java | 1 + .../plot/database/SQLManager.java | 4 ++++ .../plot/generator/HybridUtils.java | 4 +++- .../plot/util/ExpireManager.java | 4 ++-- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index dc31a26bf..a2bb715dd 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.0 + 2.11.3 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 6f69eee40..ff71fa193 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -848,6 +848,7 @@ public class PlotSquared { options.put("clear.check-disk", Settings.AUTO_CLEAR_CHECK_DISK); options.put("clear.on.ban", false); options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); + options.put("clear.auto.clear-interval-seconds", Settings.CLEAR_INTERVAL); // Schematics options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); @@ -925,6 +926,8 @@ public class PlotSquared { Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); + Settings.CLEAR_INTERVAL = config.getInt("clear.auto.clear-interval-seconds"); + // Schematics Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index fcc39c0db..1cf1f3a26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -74,7 +74,7 @@ public class MainCommand { // final int totalPages = ((int) Math.ceil(12 * (commands.size()) / // 100)); final int perPage = 5; - final int totalPages = (int) Math.ceil(commands.size() / perPage); + final int totalPages = (commands.size() / perPage) + (commands.size() % perPage == 0 ? 0 : 1); if (page > totalPages) { page = totalPages; } @@ -85,13 +85,19 @@ public class MainCommand { final List help = new ArrayList<>(); help.add(C.HELP_HEADER.s()); // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"), - help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size())); + help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size())); SubCommand cmd; final int start = page * perPage; for (int x = start; x < max; x++) { cmd = commands.get(x); String s = t(C.HELP_ITEM.s()); - s = s.replace("%alias%", cmd.alias.get(0)).replace("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage).replace("%cmd%", cmd.cmd).replace("%desc%", cmd.description); + if (cmd.alias.size() > 0) { + s = s.replace("%alias%", cmd.alias.get(0)); + } + else { + s = s.replace("%alias%", ""); + } + s = s.replace("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage).replace("%cmd%", cmd.cmd).replace("%desc%", cmd.description).replace("[]", ""); help.add(s); } if (help.size() < 2) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 80dc5b21c..52796e775 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -142,6 +142,7 @@ public class Settings { public static int AUTO_CLEAR_DAYS = 360; public static boolean AUTO_CLEAR_CHECK_DISK = false; public static int MIN_BLOCKS_CHANGED = -1; + public static int CLEAR_INTERVAL = 120; /** * API Location */ 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 c629aa365..3fa6f9628 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -676,6 +676,10 @@ public class SQLManager implements AbstractDB { stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); + stmt.close(); stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ?"); stmt.setString(1, world); stmt.setInt(2, plot.hashCode()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index d5112db8b..96097ad3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -75,6 +75,7 @@ public abstract class HybridUtils { boolean c1 = MainUtil.isPlotArea(new Location(plotworld.worldname, x, 1, z)); boolean c2 = MainUtil.isPlotArea(new Location(plotworld.worldname, ex, 1, ez)); if (!c1 && !c2) { + System.out.print("FALSE!"); return false; } else { @@ -112,7 +113,8 @@ public abstract class HybridUtils { } boolean condition; if (toCheck) { - condition = MainUtil.isPlotRoad(new Location(plotworld.worldname, x + X, 1, z + Z)); + condition = manager.getPlotId(plotworld, x + X, 1, z + Z) == null; +// condition = MainUtil.isPlotRoad(new Location(plotworld.worldname, x + X, 1, z + Z)); } else { final boolean gx = absX > plotworld.PATH_WIDTH_LOWER; final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 1858e1789..610ed09d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -65,7 +65,7 @@ public class ExpireManager { } public static void runTask() { - ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, new Runnable() { + ExpireManager.task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { for (final String world : PlotSquared.getPlotWorldsString()) { @@ -131,7 +131,7 @@ public class ExpireManager { return; } } - }, 2400, 2400); + }, Settings.CLEAR_INTERVAL * 20); } public static boolean isExpired(final UUID uuid) {