From e1dea5a4505ae47d194715feea74427bd80c5fd1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 20 Dec 2014 11:24:29 +1100 Subject: [PATCH] Fixed purge command --- .../com/intellectualcrafters/plot/commands/Purge.java | 7 +++++-- .../intellectualcrafters/plot/database/SQLManager.java | 8 ++++---- .../intellectualcrafters/plot/listeners/PlotListener.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) 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 b42e3a5c8..a9bf7ed82 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -43,8 +43,6 @@ import org.bukkit.entity.Player; final String world = split[0]; final PlotId id = new PlotId(Integer.parseInt(split[1]), Integer.parseInt(split[2])); - System.out.print("VALID ID"); - if (plr != null) { PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; @@ -54,11 +52,16 @@ import org.bukkit.entity.Player; PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); return false; } + PlotMain.getPlots(world).remove(id); DBFunc.purge(world, id); PlayerFunctions.sendMessage(null, "&aPurge of '" + args[0] + "' was successful!"); return true; } catch (final Exception e) { + if (args.length == 1) { + PlayerFunctions.sendMessage(plr, "This is a dangerous command, if you are sure, use /plot purge {world} -o"); + return false; + } PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); } } 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 5abe613a2..68916aa69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -783,14 +783,14 @@ public class SQLManager implements AbstractDB { if (ids.size() > 0) { try { - String prefix = ""; + String p = ""; final StringBuilder idstr = new StringBuilder(""); for (final Integer id : ids) { - idstr.append(prefix + id); - prefix = " OR `plot_plot_id` = "; + idstr.append(p + id); + p = " OR `plot_plot_id` = "; } - + PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 2e03adc71..cfd558cfd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -185,7 +185,7 @@ import java.util.UUID; if (plot.settings.getFlag("weather") != null) { player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue())); } - if (booleanFlag(plot, "titles") && Settings.TITLES && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { + if ((booleanFlag(plot, "titles") || Settings.TITLES) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); final ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());