Fixed /p and /a incompatibilities with bChatManager

This commit is contained in:
bm01 2012-05-02 00:55:43 +02:00
parent 06ede80435
commit 84e36d758e
2 changed files with 40 additions and 40 deletions

View File

@ -17,6 +17,8 @@ Version 1.3.07
+ Added a permission node for Farmer's Diet + Added a permission node for Farmer's Diet
+ Added config options for enabling/disabling specific double drops + Added config options for enabling/disabling specific double drops
+ Added automatic zip backup of flatfile database & config files + 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 NPE when user clicked the HUD button with Spout
= Fixed bug where the permission node for Impact didn't work = Fixed bug where the permission node for Impact didn't work
= Fixed some bypass nodes defaulting true for Ops = Fixed some bypass nodes defaulting true for Ops
@ -38,7 +40,6 @@ Version 1.3.06
+ Added API functions for admin & party chat + Added API functions for admin & party chat
+ Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed.
+ Added some new languages to the locale files. + Added some new languages to the locale files.
= Fixed Iron Grip working reversely
= Fixed Green Thumb consuming 2 seeds instead of 1 = 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 exploit where you could teleport to yourself with PTP to prevent things like fall damage
= Fixed NPE error with Metrics on startup = Fixed NPE error with Metrics on startup

View File

@ -286,60 +286,59 @@ public class PlayerListener implements Listener {
* *
* @param event The event to watch * @param event The event to watch
*/ */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) { public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
boolean partyChat = PP.getPartyChatMode();
boolean adminChat = PP.getAdminChatMode();
Set<Player> recipients = event.getRecipients();
Set<Player> intendedRecipients = new HashSet<Player>(); if (PP.getPartyChatMode()) {
ChatColor color = null;
if (partyChat || adminChat) {
if (partyChat) {
if (!PP.inParty()) { if (!PP.inParty()) {
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
return; return;
} }
color = ChatColor.GREEN;
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage()); McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent); plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return; if(chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage()); event.setMessage(chatEvent.getMessage());
Set<Player> intendedRecipients = new HashSet<Player>();
for (Player x : Party.getInstance().getOnlineMembers(player)) { for (Player x : Party.getInstance().getOnlineMembers(player)) {
intendedRecipients.add(x); intendedRecipients.add(x);
} }
event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s"); ChatColor bracketColor = ChatColor.GREEN;
event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s");
event.getRecipients().retainAll(intendedRecipients);
} }
else if (PP.getAdminChatMode()) {
if (adminChat) {
color = ChatColor.AQUA;
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage()); McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent); plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return; if(chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage()); event.setMessage(chatEvent.getMessage());
Set<Player> intendedRecipients = new HashSet<Player>();
for (Player x : plugin.getServer().getOnlinePlayers()) { for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || Permissions.getInstance().adminChat(x)) { if (x.isOp() || Permissions.getInstance().adminChat(x)) {
intendedRecipients.add(x); intendedRecipients.add(x);
} }
} }
event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s"); ChatColor bracketColor = ChatColor.AQUA;
}
recipients.retainAll(intendedRecipients); event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s");
event.getRecipients().retainAll(intendedRecipients);
} }
} }