public class ServerCommandEvent extends ServerEvent implements Cancellable
很多插件都不使用此事件.如果这个事件不是必要的,你应该尽量避免使用它!
正确使用该事件的事例如下:
${ip:Steve}
,或者模拟@a
和@p
作为装饰命令方块,插件不处理它./calias cr gamemode creative
后,下一次运行命令/cr
,它将会被替换成/gamemode creative
(全局命令别名应该通过注册的别名来完成)不正确使用该事件的事例如下:
如果事件被取消,处理命令将停止.
Event.Result
构造器和说明 |
---|
ServerCommandEvent(CommandSender sender,
java.lang.String command) |
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getCommand()
得到从控制台执行的命令(触发这个事件的命令).
|
static HandlerList |
getHandlerList() |
HandlerList |
getHandlers() |
CommandSender |
getSender()
得到命令发送者(后台).
|
boolean |
isCancelled()
获取这个事件是否被取消.一个被取消的事件不会在服务器里被执行,但是仍然会传递事件到其他插件。
|
void |
setCancelled(boolean cancel)
取消这个事件.
|
void |
setCommand(java.lang.String message)
设置将要执行的命令.
|
getEventName, isAsynchronous
public ServerCommandEvent(CommandSender sender, java.lang.String command)
public java.lang.String getCommand()
原文:Gets the command that the user is attempting to execute from the console
public void setCommand(java.lang.String message)
原文:Sets the command that the server will execute
message
- 控制台将会执行的命令public CommandSender getSender()
原文:Get the command sender.
public HandlerList getHandlers()
getHandlers
在类中 Event
public static HandlerList getHandlerList()
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
- 如果你想取消这个事件,则为true