JSimpleCommand
abstract class JSimpleCommand @JvmOverloads constructor(owner: CommandOwner, primaryName: String, secondaryNames: String, basePermission: Permission = owner.parentPermission) : SimpleCommand
Java 实现:
public final class MySimpleCommand extends JSimpleCommand {
public static final MySimpleCommand INSTANCE = new MySimpleCommand();
private MySimpleCommand() {
super(MyPlugin.INSTANCE, "tell");
// 可选设置如下属性
setDescription("这是一个测试指令");
setUsage("/tell <target> <message>"); // 如不设置则自动根据带有 @Handler 的方法生成
setPermission(CommandPermission.Operator.INSTANCE);
setPrefixOptional(true);
}
@Handler
public void onCommand(CommandSender sender, User target, String message) {
target.sendMessage(message);
}
}
Content copied to clipboard
其中 CommandSender
也可以替换为 CommandContext
,可通过 CommandContext.originalMessage 获得触发指令的原消息链。
See also
Constructors
Link copied to clipboard
constructor(owner: CommandOwner, primaryName: String, vararg secondaryNames: String, basePermission: Permission = owner.parentPermission)
Functions
Link copied to clipboard
inline suspend fun Command.execute(sender: CommandSender, vararg arguments: Message = emptyArray(), checkPermission: Boolean = true): CommandExecuteResult
inline suspend fun Command.execute(sender: CommandSender, arguments: String = "", checkPermission: Boolean = true): CommandExecuteResult
执行一个确切的指令
Link copied to clipboard
Link copied to clipboard
Properties
Link copied to clipboard
获取所有指令名称 (包含 primaryName 和 secondaryNames).
Link copied to clipboard
指令参数环境.
Link copied to clipboard
描述, 用于显示在 BuiltInCommands.HelpCommand
Link copied to clipboard
Link copied to clipboard
指令可能的参数列表.
Link copied to clipboard
指令拥有者.
Link copied to clipboard
为此指令分配的权限.
Link copied to clipboard
为 true
时表示 指令前缀 可选.
Link copied to clipboard
主指令名. 将会参与构成 Permission.id.
Link copied to clipboard
次要指令名