diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/src/main/java/com/gmail/nossr50/chat/ChatManager.java index e0df7c055..989d5feca 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -14,8 +14,8 @@ import com.gmail.nossr50.party.Party; public final class ChatManager { public ChatManager () {} - public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message); + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync); mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { @@ -36,10 +36,14 @@ public final class ChatManager { handleAdminChat(plugin, senderName, senderName, message); } - public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { + handleAdminChat(plugin, playerName, displayName, message, false); + } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) { String partyName = party.getName(); - McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message); + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync); mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { @@ -63,4 +67,8 @@ public final class ChatManager { public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) { handlePartyChat(plugin, party, senderName, senderName, message); } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { + handlePartyChat(plugin, party, playerName, displayName, message, false); + } } diff --git a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java b/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java index 9b4a2025d..ccbad7c99 100644 --- a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java +++ b/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java @@ -15,14 +15,12 @@ public class AdminChatCommand extends ChatCommand { @Override protected void handleChatSending(CommandSender sender, String[] args) { - String message = buildChatMessage(args, 0); - if (sender instanceof Player) { Player player = (Player) sender; - ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message); + ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); } else { - ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message); + ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0)); } } } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java index 2d33c4d1b..089a5917f 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java @@ -9,4 +9,8 @@ public class McMMOAdminChatEvent extends McMMOChatEvent { public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) { super(plugin, sender, displayName, message); } + + public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { + super(plugin, sender, displayName, message, isAsync); + } } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index d6c7ec6e8..d0a94f22f 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -13,7 +13,14 @@ public abstract class McMMOChatEvent extends Event implements Cancellable { private String message; protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { - super(true); + this.plugin = plugin; + this.sender = sender; + this.displayName = displayName; + this.message = message; + } + + protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { + super(isAsync); this.plugin = plugin; this.sender = sender; this.displayName = displayName; diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java index 7e03dc644..ffa54f815 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java @@ -13,6 +13,11 @@ public class McMMOPartyChatEvent extends McMMOChatEvent { this.party = party; } + public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) { + super(plugin, sender, displayName, message, isAsync); + this.party = party; + } + /** * @return String name of the party the message will be sent to */ diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 96a8d95cc..86e6eebd4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -427,11 +427,11 @@ public class PlayerListener implements Listener { return; } - ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage()); + ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage(), true); event.setCancelled(true); } else if (mcMMOPlayer.getAdminChatMode()) { - ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage()); + ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage(), true); event.setCancelled(true); } }