public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable
构造器提供了一个表示事件同步触发还是异步触发的布尔值。 当异步时,本事件可以被任何线程调用,无主线程,访问API受限。
如果玩家通过传入的聊天数据包导致触发本事件,本事件将是异步的。
如果一个插件通过迫使玩家聊天(比如Player.chat
)而触发本事件,本事件将是同步的。
应注意通过Event.isAsynchronous()
检查本事件是同步的还是异步的,适当地处理本事件。
Event.Result
player
构造器和说明 |
---|
AsyncPlayerChatEvent(boolean async,
Player who,
java.lang.String message,
java.util.Set<Player> players) |
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getFormat()
获取用于展示这条字符消息的格式。
|
static HandlerList |
getHandlerList() |
HandlerList |
getHandlers() |
java.lang.String |
getMessage()
获得这个玩家试图发送的信息。
|
java.util.Set<Player> |
getRecipients()
获取一个将看到这条消息的玩家的集合。
|
boolean |
isCancelled()
获取这个事件是否被取消.一个被取消的事件不会在服务器里被执行,但是仍然会传递事件到其他插件。
|
void |
setCancelled(boolean cancel)
取消这个事件.
|
void |
setFormat(java.lang.String format)
设置用于展示这条字符消息的格式。
|
void |
setMessage(java.lang.String message)
设置这个玩家将发送的信息。
|
getPlayer
getEventName, isAsynchronous
public java.lang.String getMessage()
getFormat()
的格式被获取。
原文:Gets the message that the player is attempting to send. This message
will be used with getFormat()
.
public void setMessage(java.lang.String message)
getFormat()
的格式被设置。
原文:Sets the message that the player will send. This message will be used
with getFormat()
.
message
- 设置的这个玩家将发送的新消息public java.lang.String getFormat()
这个事件执行完毕后,获取的格式的第一个部分是
Player.getDisplayName()
第二个部分是
原文: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()
String.format(String, Object...)
public void setFormat(java.lang.String format) throws java.util.IllegalFormatException, java.lang.NullPointerException
这个事件执行完毕后,设置的格式的第一个部分是
Player.getDisplayName()
第二个部分是
原文: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()
format
- 输出格式:String.format(String, Object...)
java.util.IllegalFormatException
- 底层API抛出错误java.lang.NullPointerException
- 如果这个格式为null则抛出错误String.format(String, Object...)
public java.util.Set<Player> getRecipients()
本方法返回的集合不保证可以改变和访问时可能自动填充。 任何监听器访问这个返回的集合应该知道对于一个lazy set的实现可能会降低性能.
监听器应注意到如果事件传唤者提供了一个不可修改的Set集合的话修改这个列表可能会抛出UnsupportedOperationException
异常。
原文: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.
public boolean isCancelled()
Cancellable
原文:Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
isCancelled
在接口中 Cancellable
public void setCancelled(boolean cancel)
Cancellable
原文:Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
setCancelled
在接口中 Cancellable
cancel
- 如果你想取消这个事件,则为truepublic HandlerList getHandlers()
getHandlers
在类中 Event
public static HandlerList getHandlerList()