Check if AsyncPlayerChatEvent is async or not. Fixes #35.
This commit is contained in:
parent
ae575ac674
commit
0c8f1c9cf1
@ -62,21 +62,6 @@ public class InternalListener implements Listener
|
|||||||
// It clears the recipient set so the event isn't cancelled completely.
|
// It clears the recipient set so the event isn't cancelled completely.
|
||||||
// It will cause non async chat events not to fire.
|
// It will cause non async chat events not to fire.
|
||||||
|
|
||||||
public static void recipientChat(Player sender, String message, String format, Set<CommandSender> recipients)
|
|
||||||
{
|
|
||||||
// For each of the recipients
|
|
||||||
for (CommandSender recipient : recipients)
|
|
||||||
{
|
|
||||||
// Run the event for this unique recipient
|
|
||||||
MCorePlayerToRecipientChatEvent recipientEvent = new MCorePlayerToRecipientChatEvent(sender, recipient, message, format);
|
|
||||||
recipientEvent.run();
|
|
||||||
|
|
||||||
// Format and send with the format and message from this recipient's own event.
|
|
||||||
String recipientMessage = String.format(recipientEvent.getFormat(), sender.getDisplayName(), recipientEvent.getMessage());
|
|
||||||
recipient.sendMessage(recipientMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void recipientChat(final AsyncPlayerChatEvent event)
|
public void recipientChat(final AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
@ -97,7 +82,7 @@ public class InternalListener implements Listener
|
|||||||
for (Player recipient : players)
|
for (Player recipient : players)
|
||||||
{
|
{
|
||||||
// Run the event for this unique recipient
|
// Run the event for this unique recipient
|
||||||
recipientEvent = new MCorePlayerToRecipientChatEvent(sender, recipient, message, format);
|
recipientEvent = new MCorePlayerToRecipientChatEvent(event.isAsynchronous(), sender, recipient, message, format);
|
||||||
recipientEvent.run();
|
recipientEvent.run();
|
||||||
|
|
||||||
// Format and send with the format and message from this recipient's own event.
|
// Format and send with the format and message from this recipient's own event.
|
||||||
@ -106,7 +91,7 @@ public class InternalListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For the console
|
// For the console
|
||||||
recipientEvent = new MCorePlayerToRecipientChatEvent(sender, Bukkit.getConsoleSender(), message, format);
|
recipientEvent = new MCorePlayerToRecipientChatEvent(event.isAsynchronous(), sender, Bukkit.getConsoleSender(), message, format);
|
||||||
recipientEvent.run();
|
recipientEvent.run();
|
||||||
event.setMessage(recipientEvent.getMessage());
|
event.setMessage(recipientEvent.getMessage());
|
||||||
event.setFormat(recipientEvent.getFormat());
|
event.setFormat(recipientEvent.getFormat());
|
||||||
|
@ -36,9 +36,9 @@ public class MCorePlayerToRecipientChatEvent extends MCoreEvent
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public MCorePlayerToRecipientChatEvent(Player sender, CommandSender recipient, String message, String format)
|
public MCorePlayerToRecipientChatEvent(boolean async, Player sender, CommandSender recipient, String message, String format)
|
||||||
{
|
{
|
||||||
super(true);
|
super(async);
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
Loading…
Reference in New Issue
Block a user