From bc4fd7d88714f154f8f05b65a109dea128662aff Mon Sep 17 00:00:00 2001 From: ElgarL Date: Wed, 5 Dec 2012 17:36:35 +0000 Subject: [PATCH] v0.35: - Fix chat spy. --- src/changelog.txt | 4 ++- .../TownyChat/channels/StandardChannel.java | 25 ++++++++++++++++++- src/plugin.yml | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/changelog.txt b/src/changelog.txt index 1b467a7..a96df75 100644 --- a/src/changelog.txt +++ b/src/changelog.txt @@ -132,4 +132,6 @@ v0.32: v0.33: - Only modify the chat format if modify_chat = true for all channels. v0.34: - - Make sure craftIRC is loaded first (if using) \ No newline at end of file + - Make sure craftIRC is loaded first (if using) +v0.35: + - Fix chat spy. \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java index c4aad9e..c3a3aa5 100644 --- a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java +++ b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java @@ -66,6 +66,7 @@ public class StandardChannel extends Channel { } Format = ChatSettings.getRelevantFormatGroup(player).getTOWN(); recipients = new HashSet(findRecipients(player, TownyUniverse.getOnlinePlayers(town))); + recipients = checkSpying(recipients); break; case NATION: @@ -75,6 +76,7 @@ public class StandardChannel extends Channel { } Format = ChatSettings.getRelevantFormatGroup(player).getNATION(); recipients = new HashSet(findRecipients(player, TownyUniverse.getOnlinePlayers(nation))); + recipients = checkSpying(recipients); break; case DEFAULT: @@ -145,7 +147,6 @@ public class StandardChannel extends Channel { } - /** * Check the distance between players and return a result based upon the range setting * -1 = no limit @@ -224,5 +225,27 @@ public class StandardChannel extends Channel { return recipients; } + + /** + * Add all spying players to the recipients list. + * + * @param recipients + * @return new recipients including spying. + */ + private Set checkSpying(Set recipients) { + + List allOnline = new ArrayList(Arrays.asList(BukkitTools.getOnlinePlayers())); + + // Compile the list of recipients with spy perms + for (Player test : allOnline) { + + if ((plugin.getTowny().hasPlayerMode(test, "spy")) && !(recipients.contains(test))) { + recipients.add(test); + } + + } + + return recipients; + } } diff --git a/src/plugin.yml b/src/plugin.yml index aea8174..68693de 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TownyChat main: com.palmergames.bukkit.TownyChat.Chat -version: 0.34 +version: 0.35 author: ElgarL, Shade, phrstbrn website: http://code.google.com/a/eclipselabs.org/p/towny/ description: >