mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
McMMOChatEvent: added a field to hold the dispatching plugin
Currently, there is no sane way to detect which plugin dispatched an McMMOChatEvent. This is problematic for plugins using the ChatAPI while also listening for McMMOChatEvents as it leads to a message loop being created. A "simple" solution is to store a reference to the dispatching plugin in the McMMOChatEvent. This allows for a plugin to determine if it is an event dispatched by itself, or some other plugin. In addition, this can allow for better control within third party plugins to determine where McMMOChatEvents are dispatched from. This patch is backwards with existing interfaces.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
@ -11,8 +12,8 @@ import com.gmail.nossr50.party.Party;
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(String playerName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, message);
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@ -30,10 +31,14 @@ public final class ChatManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Party party, String playerName, String message) {
|
||||
String partyName = party.getName();
|
||||
public static void handleAdminChat(String playerName, String message) {
|
||||
handleAdminChat(null, playerName, message);
|
||||
}
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, message);
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String message) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, partyName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@ -48,4 +53,8 @@ public final class ChatManager {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + partyMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Party party, String playerName, String message) {
|
||||
handlePartyChat(null, party, playerName, message);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user