mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-26 10:44: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,5 +1,7 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.ChatManager;
|
||||
|
||||
@ -11,10 +13,27 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendPartyChat(Plugin, String, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
ChatManager.handlePartyChat(PartyManager.getParty(party), sender, message);
|
||||
}
|
||||
@ -24,9 +43,25 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
ChatManager.handleAdminChat(plugin, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendAdminChat(Plugin, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
ChatManager.handleAdminChat(sender, message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user