Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.event.player.AsyncPlayerChatEvent Class Reference
Inheritance diagram for org.bukkit.event.player.AsyncPlayerChatEvent:
org.bukkit.event.player.PlayerEvent org.bukkit.event.Cancellable org.bukkit.event.Event

Public Member Functions

 AsyncPlayerChatEvent (final boolean async, final Player who, final String message, final Set< Player > players)
 
String getMessage ()
 
void setMessage (String message)
 
String getFormat ()
 
void setFormat (final String format) throws IllegalFormatException, NullPointerException
 
Set< PlayergetRecipients ()
 
boolean isCancelled ()
 
void setCancelled (boolean cancel)
 
HandlerList getHandlers ()
 
- Public Member Functions inherited from org.bukkit.event.player.PlayerEvent
 PlayerEvent (final Player who)
 
final Player getPlayer ()
 
- Public Member Functions inherited from org.bukkit.event.Event
 Event ()
 
 Event (boolean isAsync)
 
String getEventName ()
 
abstract HandlerList getHandlers ()
 
final boolean isAsynchronous ()
 

Static Public Member Functions

static HandlerList getHandlerList ()
 

Additional Inherited Members

- Protected Attributes inherited from org.bukkit.event.player.PlayerEvent
Player player
 

Detailed Description

This event will sometimes fire synchronously, depending on how it was triggered.

The constructor provides a boolean to indicate if the event was fired synchronously or asynchronously. When asynchronous, this event can be called from any thread, sans the main thread, and has limited access to the API.

If a player is the direct cause of this event by an incoming packet, this event will be asynchronous. If a plugin triggers this event by compelling a player to chat, this event will be synchronous.

Care should be taken to check isAsynchronous() and treat the event appropriately.

Definition at line 26 of file AsyncPlayerChatEvent.java.

Constructor & Destructor Documentation

org.bukkit.event.player.AsyncPlayerChatEvent.AsyncPlayerChatEvent ( final boolean  async,
final Player  who,
final String  message,
final Set< Player players 
)
Parameters
asyncThis changes the event to a synchronous state.
whothe chat sender
messagethe message sent
playersthe players to receive the message. This may be a lazy or unmodifiable collection.

Definition at line 41 of file AsyncPlayerChatEvent.java.

41  {
42  super(who, async);
43  this.message = message;
44  recipients = players;
45  }

Member Function Documentation

String org.bukkit.event.player.AsyncPlayerChatEvent.getFormat ( )

Gets the format to use to display this chat message.

When this event finishes execution, the first format parameter is the Player#getDisplayName() and the second parameter is getMessage()

Returns
String#format(String, Object...) compatible format string

Definition at line 77 of file AsyncPlayerChatEvent.java.

77  {
78  return format;
79  }
String org.bukkit.event.player.AsyncPlayerChatEvent.getMessage ( )

Gets the message that the player is attempting to send. This message will be used with getFormat().

Returns
Message the player is attempting to send

Definition at line 53 of file AsyncPlayerChatEvent.java.

53  {
54  return message;
55  }
Set<Player> org.bukkit.event.player.AsyncPlayerChatEvent.getRecipients ( )

Gets a set of recipients that this chat message will be displayed to.

The set returned is not guaranteed to be mutable and may auto-populate on access. Any listener accessing the returned set should be aware that it may reduce performance for a lazy set implementation.

Listeners should be aware that modifying the list may throw UnsupportedOperationException if the event caller provides an unmodifiable set.

Returns
All Players who will see this chat message

Definition at line 120 of file AsyncPlayerChatEvent.java.

120  {
121  return recipients;
122  }
boolean org.bukkit.event.player.AsyncPlayerChatEvent.isCancelled ( )

Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

Returns
true if this event is cancelled

Implements org.bukkit.event.Cancellable.

Definition at line 124 of file AsyncPlayerChatEvent.java.

124  {
125  return cancel ;
126  }
void org.bukkit.event.player.AsyncPlayerChatEvent.setCancelled ( boolean  cancel)

Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

Parameters
canceltrue if you wish to cancel this event

Implements org.bukkit.event.Cancellable.

Definition at line 128 of file AsyncPlayerChatEvent.java.

128  {
129  this.cancel = cancel;
130  }
void org.bukkit.event.player.AsyncPlayerChatEvent.setFormat ( final String  format) throws IllegalFormatException, NullPointerException

Sets the format to use to display this chat message.

When this event finishes execution, the first format parameter is the Player#getDisplayName() and the second parameter is getMessage()

Parameters
formatString#format(String, Object...) compatible format string
Exceptions
IllegalFormatExceptionif the underlying API throws the exception
NullPointerExceptionif format is null
See also
String::format(String, Object...)

Definition at line 95 of file AsyncPlayerChatEvent.java.

95  {
96  // Oh for a better way to do this!
97  try {
98  String.format(format, player, message);
99  } catch (RuntimeException ex) {
100  ex.fillInStackTrace();
101  throw ex;
102  }
103 
104  this.format = format;
105  }
void org.bukkit.event.player.AsyncPlayerChatEvent.setMessage ( String  message)

Sets the message that the player will send. This message will be used with getFormat().

Parameters
messageNew message that the player will send

Definition at line 63 of file AsyncPlayerChatEvent.java.

63  {
64  this.message = message;
65  }

The documentation for this class was generated from the following file: