From a30e8eec9a7b9323e6ddece9d4586c1783460f91 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 6 Nov 2014 18:23:21 +1100 Subject: [PATCH] various fixes --- .../java/com/intellectualcrafters/plot/PlotMain.java | 5 ++++- .../com/intellectualcrafters/plot/PlotSettings.java | 12 ++++++++++++ .../intellectualcrafters/plot/commands/Inbox.java | 2 ++ .../intellectualcrafters/plot/commands/Purge.java | 7 +------ .../intellectualcrafters/plot/commands/Visit.java | 3 +-- .../plot/database/SQLManager.java | 10 +++++++++- PlotSquared/src/main/resources/plugin.yml | 2 +- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 3d34510ad..5298ed226 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -1179,10 +1179,13 @@ public class PlotMain extends JavaPlugin { worlds = new HashSet(); } if ((generator != null) && (generator instanceof PlotGenerator)) { - sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'."); + sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); final PlotGenerator plotgen = (PlotGenerator) generator; + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - generator: &7" + generator.getClass().getName()); final PlotWorld plotworld = plotgen.getNewPlotWorld(world); + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotworld.getClass().getName()); final PlotManager manager = plotgen.getPlotManager(); + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + manager.getClass().getName()); if (!config.contains("worlds." + world)) { config.createSection("worlds." + world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSettings.java index 8f5d0b785..6ecf6a10a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSettings.java @@ -178,7 +178,19 @@ public class PlotSettings { public void setComments(final ArrayList comments) { this.comments = comments; } + + public void removeComment(PlotComment comment) { + if (this.comments.contains(comment)) { + this.comments.remove(comment); + } + } + public void removeComments(ArrayList comments) { + for (PlotComment comment : comments) { + removeComment(comment); + } + } + public void addComment(final PlotComment comment) { if (this.comments == null) { this.comments = new ArrayList(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index acc3029e3..93ebc3a68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -138,6 +138,7 @@ public class Inbox extends SubCommand { final int index = Integer.parseInt(split[1]); final PlotComment comment = comments.get(index - 1); DBFunc.removeComment(world, plot, comment); + plot.settings.removeComment(comment); PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); return; } @@ -149,6 +150,7 @@ public class Inbox extends SubCommand { for (final PlotComment comment : comments) { DBFunc.removeComment(world, plot, comment); } + plot.settings.removeComments(comments); PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); return; } 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 4daa5d157..9b549ba86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -59,15 +59,10 @@ public class Purge extends SubCommand { return false; } if (args[1].equals("-o")) { - final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]); - if (plotworld == null) { + if (PlotMain.getPlots(args[0])==null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } - if (plr != null) { - PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); - return false; - } PlotMain.removePlotWorld(args[0]); DBFunc.purge(args[0]); PlayerFunctions.sendMessage(plr, (C.PURGE_SUCCESS)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index b49b27288..a7b112b87 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -28,14 +28,13 @@ public class Visit extends SubCommand { public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); for (final Plot p : PlotMain.getPlots()) { - if (p.owner.equals(uuid)) { + if (p.hasOwner() && p.owner.equals(uuid)) { plots.add(p); } } return plots; } - @SuppressWarnings("deprecation") @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 ef557214d..5c823e634 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -297,6 +297,9 @@ public class SQLManager extends AbstractDB { stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); + stmt = connection.prepareStatement("DELETE FROM `" + PREFIX + "plot_comments` WHERE `plot_plot_id` = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); stmt = connection.prepareStatement("DELETE FROM `" + PREFIX + "plot` WHERE `id` = ?"); stmt.setInt(1, id); stmt.executeUpdate(); @@ -596,8 +599,13 @@ public class SQLManager extends AbstractDB { } newplots.get(world).put(plot.id, plot); } + boolean invalidPlot = false; for (final String worldname : noExist.keySet()) { - PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'!!!\n&c - Please create this world, or remove the plots from the DB using the purge command!"); + invalidPlot = true; + PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); + } + if (invalidPlot) { + PlotMain.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); } } catch (final SQLException e) { diff --git a/PlotSquared/src/main/resources/plugin.yml b/PlotSquared/src/main/resources/plugin.yml index b68f27176..0971c5d4f 100644 --- a/PlotSquared/src/main/resources/plugin.yml +++ b/PlotSquared/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: PlotSquared main: com.intellectualcrafters.plot.PlotMain -version: 2.2.0 +version: 2.2.1 load: STARTUP description: > Easy, yet powerful Plot World generation and management.