From ea6d5778c8da49112cab4f276bfff5eccbbc743a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 1 Sep 2015 15:09:46 +1000 Subject: [PATCH] Added chat spy toggle --- .../plot/commands/Toggle.java | 34 +++++++++++++------ .../bukkit/listeners/PlayerEvents.java | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java b/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java index 32dc651ab..c6e9d2360 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java @@ -64,18 +64,32 @@ public class Toggle extends SubCommand { public Toggle() { toggles = new HashMap<>(); toggles.put("titles", - new Command("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) { - - @Override - public boolean onCommand(PlotPlayer player, String[] args) { - if (toggle(player, "disabletitles")) { - MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand()); + new Command("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) { + + @Override + public boolean onCommand(PlotPlayer player, String[] args) { + if (toggle(player, "disabletitles")) { + MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand()); + } + else { + MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand()); + } + return true; } - else { - MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand()); + }); + toggles.put("chatspy", + new Command("chatspy", "/plot toggle chatspy", "Toggle chat spying", C.PERMISSION_COMMANDS_CHAT.s()) { + + @Override + public boolean onCommand(PlotPlayer player, String[] args) { + if (toggle(player, "chatspy")) { + MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand()); + } + else { + MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand()); + } + return true; } - return true; - } }); toggles.put("chat", new Command("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) { diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index b82cb8287..d6dedea39 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -626,7 +626,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen recipients.clear(); for (final Player p : Bukkit.getOnlinePlayers()) { PlotPlayer pp = BukkitUtil.getPlayer(p); - if (Permissions.hasPermission(pp, C.PERMISSION_COMMANDS_CHAT) || plot.equals(pp.getCurrentPlot())) { + if (pp.getAttribute("chatspy") || plot.equals(pp.getCurrentPlot())) { recipients.add(p); } }