SimpleCommand

abstract class SimpleCommand(owner: CommandOwner, primaryName: String, secondaryNames: String, description: String, parentPermission: Permission, overrideContext: CommandArgumentContext) : AbstractCommand, Command, CommandArgumentContextAware

简单的, 支持参数自动解析的指令.

要查看指令解析流程, 参考 CommandManager.executeCommand. 要查看参数解析方式, 参考 CommandValueArgumentParser.

Java 示例查看 JSimpleCommand.

Kotlin 示例:

object MySimpleCommand : SimpleCommand(
MyPlugin, "tell",
description = "Message somebody"
) {
@Handler
suspend fun CommandSender.onCommand(target: User, message: String) {
target.sendMessage(message)
}
}

See also

Constructors

SimpleCommand
Link copied to clipboard
fun SimpleCommand(owner: CommandOwner, primaryName: String, vararg secondaryNames: String, description: String = "no description available", parentPermission: Permission = owner.parentPermission, overrideContext: CommandArgumentContext = EmptyCommandArgumentContext)

Properties

context
Link copied to clipboard
open override val context: CommandArgumentContext

指令参数环境. 默认为 CommandArgumentContext.Builtins+overrideContext

description
Link copied to clipboard
abstract val description: String

描述, 用于显示在 BuiltInCommands.HelpCommand

overloads
Link copied to clipboard

指令可能的参数列表.

owner
Link copied to clipboard
abstract val owner: CommandOwner

指令拥有者.

permission
Link copied to clipboard
abstract val permission: Permission

为此指令分配的权限.

prefixOptional
Link copied to clipboard

true 时表示 指令前缀 可选.

primaryName
Link copied to clipboard
abstract val primaryName: String

主指令名. 将会参与构成 Permission.id.

secondaryNames
Link copied to clipboard
abstract val secondaryNames: Array<out String>

次要指令名

usage
Link copied to clipboard
open override val usage: String

自动根据带有 Handler 注解的函数签名生成 usage. 也可以被覆盖.

Inheritors

HelpCommand
Link copied to clipboard
StopCommand
Link copied to clipboard
LogoutCommand
Link copied to clipboard
LoginCommand
Link copied to clipboard
StatusCommand
Link copied to clipboard
JSimpleCommand
Link copied to clipboard