diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index f3e1910e1..f15138555 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -201,7 +201,7 @@ public class Auto extends SubCommand { } public PlotId getLastPlot(String world) { - if (PlotHelper.lastPlot == null) { + if (PlotHelper.lastPlot == null || !PlotHelper.lastPlot.containsKey(world)) { PlotHelper.lastPlot.put(world, new PlotId(0,0)); } return PlotHelper.lastPlot.get(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index ee08ead9e..441d901a9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.UUIDHandler; -@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Purge extends SubCommand { +@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand { public Purge() { super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false); @@ -124,6 +124,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } if (arg.equals("all")) { Set ids = PlotMain.getPlots(world).keySet(); + if (ids.size() == 0) { + return PlayerFunctions.sendMessage(null, "&cNo plots found"); + } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } @@ -138,6 +141,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } } } + if (ids.size() == 0) { + return PlayerFunctions.sendMessage(null, "&cNo plots found"); + } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } @@ -149,6 +155,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler; ids.add(plot.id); } } + if (ids.size() == 0) { + return PlayerFunctions.sendMessage(null, "&cNo plots found"); + } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } 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 1e73e3fdf..b6eaf8067 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -831,37 +831,36 @@ public class SQLManager implements AbstractDB { } /** - * Purge all plots with the f ollowing database IDs + * Purge all plots with the following database IDs */ public void purgeIds(final String world, final Set uniqueIds) { if (uniqueIds.size() > 0) { try { - String prefix = ""; + String stmt_prefix = ""; final StringBuilder idstr = new StringBuilder(""); for (final Integer id : uniqueIds) { - idstr.append(prefix + id); - prefix = " OR `plot_plot_id` = "; + idstr.append(stmt_prefix + id); + stmt_prefix = " OR `plot_plot_id` = "; } - - PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + ""); + PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + ""); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + ""); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + ""); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot` WHERE `world` = ?"); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot` WHERE `world` = ?"); stmt.setString(1, world); stmt.executeUpdate(); stmt.close(); @@ -875,6 +874,9 @@ public class SQLManager implements AbstractDB { } @Override public void purge(final String world, Set plots) { + for (PlotId id : plots) { + PlotMain.removePlot(world, id, true); + } PreparedStatement stmt; try { stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?");