public interface CommandExecutor
PluginContainer,
onCommand(org.cloudburstmc.server.command.CommandSender, org.cloudburstmc.server.command.Command, java.lang.String, java.lang.String[])| Modifier and Type | Method and Description |
|---|---|
boolean |
onCommand(CommandSender sender,
Command command,
String label,
String[] args)
在命令执行时会调用的方法。
Called when a command is executed. |
boolean onCommand(CommandSender sender, Command command, String label, String[] args)
一个命令可以是/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
variable label is "a_label", and the values of elements of array args are
"an_arg1","AN_ARG2",.... Notice that the value of variable label will be converted to
lower case, but the cases of elements of array args won't change.
关于返回值,如果返回false,Nukkit会给sender发送这个命令的使用方法等信息,来表示这个命令没有使用成功。
如果你的命令成功的发挥了作用,你应该返回true来表示这个命令已执行成功。
If this function returns false, Nukkit will send command usages to command sender, to explain that
the command didn't work normally. If your command works properly, a true should be returned to explain
that the command works.
如果你想测试一个命令发送者是否有权限执行这个命令,
可以使用Command.testPermissionSilent(org.cloudburstmc.server.command.CommandSender)。
If you want to test whether a command sender has the permission to execute a command,
you can use Command.testPermissionSilent(org.cloudburstmc.server.command.CommandSender).
sender - 这个命令的发送者,可以是玩家或控制台等。command - 要被发送的命令。label - 这个命令的标签。args - 这个命令的参数列表。Copyright © 2020. All rights reserved.