mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-31 06:39:36 +01:00
Changes to the changes to the ChatAPI.
mcMMO will not pass null for any events that it creates about itself. Older plugins which are using depricated methods in ChatAPI will be null. Newer plugins passing null to ChatAPI will also be null. Null guarantees that it is not from mcMMO, but from an external plugin that is not specified.
This commit is contained in:
parent
251c152efa
commit
7ccadae489
@ -36,6 +36,7 @@ Version 1.4.00-dev
|
||||
! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values
|
||||
! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API.
|
||||
! Changed the way party commands work, use /party ? to check how to use the new commands
|
||||
! Changed McMMOChatEvent to contain the plugin that the event originated from.
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
|
@ -35,7 +35,7 @@ public final class ChatAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
ChatManager.handlePartyChat(PartyManager.getParty(party), sender, message);
|
||||
sendPartyChat(null, party, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,6 +63,6 @@ public final class ChatAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
ChatManager.handleAdminChat(sender, message);
|
||||
sendAdminChat(null, sender, message);
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,4 @@ public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String message) {
|
||||
super(plugin, sender, message);
|
||||
}
|
||||
|
||||
public McMMOAdminChatEvent(String sender, String message) {
|
||||
this(null, sender, message);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class McMMOChatEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private Plugin plugin;
|
||||
@ -14,17 +12,13 @@ public class McMMOChatEvent extends Event implements Cancellable {
|
||||
private String message;
|
||||
|
||||
protected McMMOChatEvent(Plugin plugin, String sender, String message) {
|
||||
if (plugin == null) {
|
||||
plugin = mcMMO.p;
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The plugin responsible for this event
|
||||
* @return The plugin responsible for this event, note this can be null
|
||||
*/
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
|
@ -13,10 +13,6 @@ public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||
this(null, sender, party, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the party the message will be sent to
|
||||
*/
|
||||
|
@ -341,11 +341,11 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(party, player.getName(), event.getMessage());
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (profile.getAdminChatMode()) {
|
||||
ChatManager.handleAdminChat(player.getName(), event.getMessage());
|
||||
ChatManager.handleAdminChat(plugin, player.getName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class ACommand implements CommandExecutor {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(mcMMO.p, player.getName(), message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@ -80,7 +80,7 @@ public class ACommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message);
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(mcMMO.p, "Console", message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
|
@ -74,7 +74,7 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@ -111,7 +111,7 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, "Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
|
@ -31,10 +31,6 @@ public final class ChatManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleAdminChat(String playerName, String message) {
|
||||
handleAdminChat(null, playerName, message);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String message) {
|
||||
String partyName = party.getName();
|
||||
|
||||
@ -53,8 +49,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user