diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index c9454a84b..872675644 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -66,7 +66,7 @@ public class Clear extends SubCommand { PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } }; - if (Settings.CONFIRM_CLEAR) { + if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { CmdConfirm.addPending(plr, "/plot clear " + id, runnable); } else { @@ -133,7 +133,7 @@ public class Clear extends SubCommand { } } }; - if (Settings.CONFIRM_CLEAR) { + if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { CmdConfirm.addPending(plr, "/plot clear " + plot.id, runnable); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 5312d57e1..48dc09b63 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -94,7 +94,7 @@ public class Condense extends SubCommand { } start = Auto.getNextPlot(start, 1); } - MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { + MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { @Override public void run() { if (!TASK) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 85e634dec..a4a844b7b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -83,7 +83,7 @@ public class Delete extends SubCommand { DBFunc.delete(loc.getWorld(), plot); } }; - if (Settings.CONFIRM_DELETE) { + if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { CmdConfirm.addPending(plr, "/plot delete " + plot.id, runnable); } else { 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 2b4bd8264..e9438a3b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -114,16 +114,18 @@ public class Purge extends SubCommand { for (final Plot plot : plots) { ids.add(plot.id); } + int length = ids.size(); DBFunc.purge(worldname, ids); - return finishPurge(ids.size()); + return finishPurge(length); } if (arg.equals("all")) { final Set ids = PlotSquared.getPlots(worldname).keySet(); - if (ids.size() == 0) { + int length = ids.size(); + if (length == 0) { return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); - return finishPurge(ids.size()); + return finishPurge(length); } if (arg.equals("unknown")) { final Collection plots = PlotSquared.getPlots(worldname).values(); @@ -136,11 +138,12 @@ public class Purge extends SubCommand { } } } - if (ids.size() == 0) { + int length = ids.size(); + if (length == 0) { return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); - return finishPurge(ids.size()); + return finishPurge(length); } if (arg.equals("unowned")) { final Collection plots = PlotSquared.getPlots(worldname).values(); @@ -150,11 +153,12 @@ public class Purge extends SubCommand { ids.add(plot.id); } } - if (ids.size() == 0) { + int length = ids.size(); + if (length == 0) { return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); - return finishPurge(ids.size()); + return finishPurge(length); } MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 81c4db8eb..e827ef7a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -74,7 +74,7 @@ public class Unlink extends SubCommand { MainUtil.sendMessage(plr, C.UNLINK_SUCCESS); } }; - if (Settings.CONFIRM_UNLINK) { + if (Settings.CONFIRM_UNLINK && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { CmdConfirm.addPending(plr, "/plot unlink " + plot.id, runnable); } else { 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 b7d82a3a2..3beeb683e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -29,6 +29,7 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Set; @@ -866,6 +867,12 @@ public class SQLManager implements AbstractDB { if (uniqueIds.size() > 0) { try { String stmt_prefix = ""; + final StringBuilder idstr2 = new StringBuilder(""); + for (final Integer id : uniqueIds) { + idstr2.append(stmt_prefix + id); + stmt_prefix = " OR `id` = "; + } + stmt_prefix = ""; final StringBuilder idstr = new StringBuilder(""); for (final Integer id : uniqueIds) { idstr.append(stmt_prefix + id); @@ -883,8 +890,7 @@ public class SQLManager implements AbstractDB { 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 `" + this.prefix + "plot` WHERE `world` = ?"); - stmt.setString(1, world); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot` WHERE `id` = " + idstr2 + ""); stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { @@ -898,9 +904,6 @@ public class SQLManager implements AbstractDB { @Override public void purge(final String world, final Set plots) { - for (final PlotId id : plots) { - PlotSquared.removePlot(world, new PlotId(id.x, id.y), true); - } PreparedStatement stmt; try { stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?"); @@ -917,6 +920,12 @@ public class SQLManager implements AbstractDB { purgeIds(world, ids); stmt.close(); r.close(); + for (Iterator iter = plots.iterator(); iter.hasNext();) { + PlotId plotId = iter.next(); + iter.remove(); + PlotId id = new PlotId(plotId.x, plotId.y); + PlotSquared.removePlot(world, new PlotId(id.x, id.y), true); + } } catch (final SQLException e) { e.printStackTrace(); PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index bcc9c0b01..04b4d0a19 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -825,12 +825,14 @@ public class MainUtil { final Location top = MainUtil.getPlotTopLoc(world, current); final Plot currentPlot = MainUtil.getPlot(world, current); if (currentPlot.owner == null) { + TaskManager.runTaskLater(whenDone, 1); return false; } final Plot pos1 = getBottomPlot(currentPlot); final Plot pos2 = getTopPlot(currentPlot); final PlotId size = MainUtil.getSize(world, currentPlot); if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + TaskManager.runTaskLater(whenDone, 1); return false; } final int offset_x = newPlot.x - pos1.id.x;