From 84e36d758eb35b21219e816226223bb7383cb8d6 Mon Sep 17 00:00:00 2001 From: bm01 Date: Wed, 2 May 2012 00:55:43 +0200 Subject: [PATCH] Fixed /p and /a incompatibilities with bChatManager --- Changelog.txt | 3 +- .../nossr50/listeners/PlayerListener.java | 77 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 02702715f..875afd68c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,8 @@ Version 1.3.07 + Added a permission node for Farmer's Diet + Added config options for enabling/disabling specific double drops + Added automatic zip backup of flatfile database & config files + = Fixed /p and /a incompatibilities with bChatManager + = Fixed Iron Grip working reversely = Fixed NPE when user clicked the HUD button with Spout = Fixed bug where the permission node for Impact didn't work = Fixed some bypass nodes defaulting true for Ops @@ -38,7 +40,6 @@ Version 1.3.06 + Added API functions for admin & party chat + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. + Added some new languages to the locale files. - = Fixed Iron Grip working reversely = Fixed Green Thumb consuming 2 seeds instead of 1 = Fixed exploit where you could teleport to yourself with PTP to prevent things like fall damage = Fixed NPE error with Metrics on startup diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 3a2c92a2c..1b32c67df 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -286,60 +286,59 @@ public class PlayerListener implements Listener { * * @param event The event to watch */ - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); PlayerProfile PP = Users.getProfile(player); - boolean partyChat = PP.getPartyChatMode(); - boolean adminChat = PP.getAdminChatMode(); - Set recipients = event.getRecipients(); - Set intendedRecipients = new HashSet(); - ChatColor color = null; + if (PP.getPartyChatMode()) { + if (!PP.inParty()) { + player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale + return; + } - if (partyChat || adminChat) { - if (partyChat) { - if (!PP.inParty()) { - player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale - return; - } + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage()); + plugin.getServer().getPluginManager().callEvent(chatEvent); - color = ChatColor.GREEN; + if(chatEvent.isCancelled()) { + return; + } - McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage()); - plugin.getServer().getPluginManager().callEvent(chatEvent); + event.setMessage(chatEvent.getMessage()); - if(chatEvent.isCancelled()) return; + Set intendedRecipients = new HashSet(); - event.setMessage(chatEvent.getMessage()); + for (Player x : Party.getInstance().getOnlineMembers(player)) { + intendedRecipients.add(x); + } - for (Player x : Party.getInstance().getOnlineMembers(player)) { + ChatColor bracketColor = ChatColor.GREEN; + + event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s"); + event.getRecipients().retainAll(intendedRecipients); + } + else if (PP.getAdminChatMode()) { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage()); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if(chatEvent.isCancelled()) { + return; + } + + event.setMessage(chatEvent.getMessage()); + + Set intendedRecipients = new HashSet(); + + for (Player x : plugin.getServer().getOnlinePlayers()) { + if (x.isOp() || Permissions.getInstance().adminChat(x)) { intendedRecipients.add(x); } - - event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s"); } - if (adminChat) { - color = ChatColor.AQUA; + ChatColor bracketColor = ChatColor.AQUA; - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage()); - plugin.getServer().getPluginManager().callEvent(chatEvent); - - if(chatEvent.isCancelled()) return; - - event.setMessage(chatEvent.getMessage()); - - for (Player x : plugin.getServer().getOnlinePlayers()) { - if (x.isOp() || Permissions.getInstance().adminChat(x)) { - intendedRecipients.add(x); - } - } - - event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s"); - } - - recipients.retainAll(intendedRecipients); + event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s"); + event.getRecipients().retainAll(intendedRecipients); } }