Interface CommandExecutor
- All Known Subinterfaces:
Plugin
- All Known Implementing Classes:
CommonJSPlugin
,InternalPlugin
,PluginBase
,PowerNukkitPlugin
An interface what can be implemented by classes which listens command executing.
- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- Author:
- MagicDroidX(code) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
onCommand
(CommandSender sender, Command command, String label, String[] args) 在命令执行时会调用的方法。
Called when a command is executed.
-
Method Details
-
onCommand
在命令执行时会调用的方法。
Called when a command is executed.一个命令可以是
/a_LABEL an_arg1 AN_ARG2...
的形式,这时label
变量的值为"a_label"
,args
数组的元素有"an_arg1","AN_ARG2",...
。注意到label
变量会被转化成小写, 而args
数组内字符串元素的大小写不变。
A command can be such a form like/a_LABEL an_arg1 AN_ARG2...
. At this time, the value of variablelabel
is"a_label"
, and the values of elements of arrayargs
are"an_arg1","AN_ARG2",...
. Notice that the value of variablelabel
will be converted to lower case, but the cases of elements of arrayargs
won't change.关于返回值,如果返回
false
,Nukkit会给sender发送这个命令的使用方法等信息,来表示这个命令没有使用成功。 如果你的命令成功的发挥了作用,你应该返回true
来表示这个命令已执行成功。
If this function returnsfalse
, Nukkit will send command usages to command sender, to explain that the command didn't work normally. If your command works properly, atrue
should be returned to explain that the command works.如果你想测试一个命令发送者是否有权限执行这个命令, 可以使用
Command.testPermissionSilent(cn.nukkit.command.CommandSender)
。
If you want to test whether a command sender has the permission to execute a command, you can useCommand.testPermissionSilent(cn.nukkit.command.CommandSender)
.- Parameters:
sender
- 这个命令的发送者,可以是玩家或控制台等。
The sender of this command, this can be a player or a console.command
- 要被发送的命令。
The command to send.label
- 这个命令的标签。
Label of the command.args
- 这个命令的参数列表。
Arguments of this command.- Returns:
- 这个命令执行是否执行成功。
whether this command is executed successfully. - Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-