From 75b287771a52117ea54d3e477bf5877141ad3da6 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Wed, 30 May 2012 11:13:34 -0400 Subject: [PATCH] Return party chat to ye olden method --- .../nossr50/commands/party/PCommand.java | 20 ++++++++++++------- .../nossr50/listeners/PlayerListener.java | 13 +++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java index f7650cce1..a1951cc6a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java @@ -30,7 +30,6 @@ public class PCommand implements CommandExecutor { return true; } - switch (args.length) { case 0: if (sender instanceof Player) { @@ -71,13 +70,20 @@ public class PCommand implements CommandExecutor { message = message + " " + args [i]; } - if (PP.getPartyChatMode()) { - player.chat(message); + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), message); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return true; } - else { - PP.togglePartyChat(); - player.chat(message); - PP.togglePartyChat(); + + message = chatEvent.getMessage(); + String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; + + plugin.getLogger().info("[P](" + PP.getParty() + ")" + "<" + player.getName() + "> " + message); + + for (Player p : Party.getInstance().getOnlineMembers(PP.getParty())) { + 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 46ae5af8b..0911f70d5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -329,18 +329,15 @@ public class PlayerListener implements Listener { return; } - event.setMessage(chatEvent.getMessage()); + String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; - Set intendedRecipients = new HashSet(); + plugin.getLogger().info("[P](" + PP.getParty() + ")" + "<" + player.getName() + "> " + chatEvent.getMessage()); - for (Player x : Party.getInstance().getOnlineMembers(player)) { - intendedRecipients.add(x); + for (Player p : Party.getInstance().getOnlineMembers(PP.getParty())) { + p.sendMessage(prefix + chatEvent.getMessage()); } - ChatColor bracketColor = ChatColor.GREEN; - - event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s"); - event.getRecipients().retainAll(intendedRecipients); + event.setCancelled(true); } else if (PP.getAdminChatMode()) { McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());