mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Fixed issue with async chatting. Closes #731
This commit is contained in:
parent
3b05bb96e3
commit
e9dcb31002
@ -14,8 +14,8 @@ import com.gmail.nossr50.party.Party;
|
|||||||
public final class ChatManager {
|
public final class ChatManager {
|
||||||
public ChatManager () {}
|
public ChatManager () {}
|
||||||
|
|
||||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
@ -36,10 +36,14 @@ public final class ChatManager {
|
|||||||
handleAdminChat(plugin, senderName, senderName, message);
|
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();
|
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);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
@ -63,4 +67,8 @@ public final class ChatManager {
|
|||||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||||
handlePartyChat(plugin, party, senderName, senderName, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,12 @@ public class AdminChatCommand extends ChatCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||||
String message = buildChatMessage(args, 0);
|
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
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 {
|
else {
|
||||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message);
|
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,8 @@ public class McMMOAdminChatEvent extends McMMOChatEvent {
|
|||||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||||
super(plugin, sender, displayName, message);
|
super(plugin, sender, displayName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
|
||||||
|
super(plugin, sender, displayName, message, isAsync);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,14 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
|
|||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, 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.plugin = plugin;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
|
@ -13,6 +13,11 @@ public class McMMOPartyChatEvent extends McMMOChatEvent {
|
|||||||
this.party = party;
|
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
|
* @return String name of the party the message will be sent to
|
||||||
*/
|
*/
|
||||||
|
@ -427,11 +427,11 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getAdminChatMode()) {
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user