From 90856e442486b64526efc7a581f135321b0fbae5 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 24 Jan 2015 18:17:11 -0700 Subject: [PATCH] fixed comments not surviving restarts. --- .../intellectualcrafters/plot/PlotMain.java | 7 +++--- .../plot/commands/Comment.java | 2 +- .../plot/commands/Inbox.java | 4 ++-- .../plot/database/SQLManager.java | 8 +++---- .../plot/listeners/PlayerEvents.java | 23 +++++++++---------- .../plot/object/PlotSettings.java | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 7deda77a4..929b41e30 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -815,7 +815,7 @@ public class PlotMain extends JavaPlugin implements Listener { options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME); options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); options.put("UUID.offline", Settings.OFFLINE_MODE); - options.put("worldguard.enabled", Settings.WORLDGUARD); +// options.put("worldguard.enabled", Settings.WORLDGUARD); options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); options.put("console.color", Settings.CONSOLE_COLOR); @@ -850,8 +850,9 @@ public class PlotMain extends JavaPlugin implements Listener { Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias"); Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled"); Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); - Settings.WORLDGUARD = config.getBoolean("worldguard.enabled"); - Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding"); +// Settings.WORLDGUARD = config.getBoolean("worldguard.enabled"); + Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + + "inding"); Settings.METRICS = config.getBoolean("metrics"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index b17661a97..3f30d653f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -52,7 +52,7 @@ public class Comment extends SubCommand { final List recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone"); - if ((args.length == 2) && recipients.contains(args[0].toLowerCase())) { + if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { if (PlotMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); 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 d81f6de52..baec7d6ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -183,8 +183,8 @@ public class Inbox extends SubCommand { final StringBuilder message = new StringBuilder(); String prefix = ""; for (final PlotComment comment : comments) { - message.append(prefix).append("[").append(count).append("]&6[&c").append(recipients.get(tier2)).append("&6] &7").append(comment.senderName).append("&f: ").append(comment.comment); - prefix = "\n"; + message.append(prefix).append("&c[").append(count).append("]&6[").append(recipients.get(tier2 == -1 ? 0 : tier2)).append("] &7").append(comment.senderName).append("&f: ").append(comment.comment); + prefix = "\n" + C.PREFIX; count++; } if (comments.size() == 0) { 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 aed8fdb48..e52645db9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1007,12 +1007,12 @@ public class SQLManager implements AbstractDB { final PreparedStatement statement; String comparison = below ? ">=" : "="; if (plot != null) { - statement = this.connection.prepareStatement("SELECT `*` FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); statement.setInt(2, tier); } else { - statement = this.connection.prepareStatement("SELECT `*` FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?"); + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?"); statement.setInt(1, tier); } final ResultSet set = statement.executeQuery(); @@ -1025,7 +1025,7 @@ public class SQLManager implements AbstractDB { } statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); + PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); e.printStackTrace(); } return comments; @@ -1046,7 +1046,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set comment for plot " + plot.id); } } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index e39595695..61f907389 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -156,19 +156,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (PlotHelper.worldBorder.containsKey(worldname)) { int border = PlotHelper.getBorder(worldname); boolean passed = false; - if (t.getBlockX() >= border) { + if (t.getBlockX() > border) { q.setX(border); passed = true; } - else if (t.getBlockX() <= -border) { + else if (t.getBlockX() < -border) { q.setX(-border); passed = true; } - if (t.getBlockZ() >= border) { + if (t.getBlockZ() > border) { q.setZ(border); passed = true; } - else if (t.getBlockZ() <= -border) { + else if (t.getBlockZ() < -border) { q.setZ(-border); passed = true; } @@ -181,15 +181,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Plot plot = getCurrentPlot(q); if (plot != null) { if (!plot.equals(getCurrentPlot(f))) { - event.setCancelled(true); - return; + if (plot.deny_entry(player)) { + if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { + event.setCancelled(true); + return; + } + } + plotEntry(player, plot); } - if (plot.deny_entry(player)) { - if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { - event.setCancelled(true); - return; - } - } } else if (leftPlot(f, q)) { plot = getCurrentPlot(event.getFrom()); plotExit(player, plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index b95ddf71e..4b2003101 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -157,7 +157,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; public ArrayList getComments(final int tier) { final ArrayList c = new ArrayList<>(); if (this.comments == null) { - return c; + return null; } for (final PlotComment comment : this.comments) { if (comment.tier == tier) {