From 90296d87dfed6d4e66ff594fb526067d450786d1 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Wed, 30 May 2012 11:18:25 -0400 Subject: [PATCH] Similarly return admin chat to ye olden method --- .../nossr50/commands/party/ACommand.java | 22 +++++++++++++------ .../nossr50/listeners/PlayerListener.java | 15 +++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java index 7e9a98ef6..6e3517296 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java @@ -63,15 +63,23 @@ public class ACommand implements CommandExecutor { if (sender instanceof Player) { Player player = (Player) sender; - PP = Users.getProfile(player); - if (PP.getAdminChatMode()) { - player.chat(message); + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return true; } - else { - PP.toggleAdminChat(); - player.chat(message); - PP.toggleAdminChat(); + + message = chatEvent.getMessage(); + String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; + + plugin.getLogger().info("[A]<" + player.getName() + "> " + message); + + for (Player p : plugin.getServer().getOnlinePlayers()) { + if (Permissions.getInstance().adminChat(player) || player.isOp()) { + p.sendMessage(prefix + message); + } } } else { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 0911f70d5..c8bbf8999 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -347,20 +347,15 @@ public class PlayerListener implements Listener { return; } - event.setMessage(chatEvent.getMessage()); + String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; - Set intendedRecipients = new HashSet(); + plugin.getLogger().info("[A]<" + player.getName() + "> " + chatEvent.getMessage()); - for (Player x : plugin.getServer().getOnlinePlayers()) { - if (x.isOp() || Permissions.getInstance().adminChat(x)) { - intendedRecipients.add(x); + for (Player p : plugin.getServer().getOnlinePlayers()) { + if (Permissions.getInstance().adminChat(player) || player.isOp()) { + p.sendMessage(prefix + chatEvent.getMessage()); } } - - ChatColor bracketColor = ChatColor.AQUA; - - event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s"); - event.getRecipients().retainAll(intendedRecipients); } }