LiteralCommandBuilder

class LiteralCommandBuilder<Source : SharedSuggestionProvider>(name: String) : CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>> (source)

Constructors

Link copied to clipboard
constructor(name: String)

Functions

Link copied to clipboard
fun alias(vararg name: String)

Adds an alias for this literal command node, which can be used instead of the main LiteralCommandBuilder.name.

Link copied to clipboard
inline fun <T> argument(name: String, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. The ArgumentType will be resolved using the reified type T. For a list of supported types, have a look at ArgumentTypeUtils.fromReifiedType, as it is the function used by this builder function.

inline fun <T> argument(name: String, type: ArgumentType<T>, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function allows you to specify the ArgumentType in the classical Brigadier way.

@JvmName(name = "argumentWithCustomParser")
inline fun <T> argument(name: String, crossinline parser: (StringReader) -> T, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function you to specifiy the argument parse logic using a Kotlin lambda function (parser).

@JvmName(name = "argumentWithContextualType")
inline fun <T> argument(name: String, noinline typeProvider: (CommandBuildContext) -> ArgumentType<T>, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function allows you to pass and argument which depends on the CommandBuildContext.

Link copied to clipboard
fun brigadier(block: LiteralArgumentBuilder<Source>.(context: CommandBuildContext) -> Unit): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

This function allows you to access the regular Brigadier builder. The type of this in its context will equal the type of Builder.

Link copied to clipboard
inline fun literal(name: String, builder: LiteralCommandBuilder<Source>.() -> Unit = {}): LiteralCommandBuilder<Source>

Adds a new subcommand / literal to this command.

Link copied to clipboard
fun requires(predicate: (source: Source) -> Boolean): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Specifies that the given predicate must return true for the Source in order for it to be able to execute this part of the command tree. Use this function on the root command node to secure the whole command.

Link copied to clipboard
fun requiresPermissionLevel(level: Int): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Specifies that the given permission level is required to execute this part of the command tree. A shortcut delegating to requires.

fun requiresPermissionLevel(level: PermissionLevel): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Specifies that the PermissionLevel given as level is required to execute this part of the command tree. A shortcut delegating to requires.

Link copied to clipboard
infix inline fun runs(crossinline block: CommandContext<Source>.() -> Unit): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Adds execution logic to this command. The place where this function is called matters, as this defines for which path in the command tree this executor should be called.

Link copied to clipboard
infix inline fun runsAsync(crossinline block: suspend CommandContext<Source>.() -> Unit): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Does the same as runs (see its docs for more information), but launches the command logic in an async coroutine.

Link copied to clipboard
infix inline fun simpleExecutes(crossinline executor: CommandContext<Source>.() -> Unit): CommandBuilder<Source, LiteralArgumentBuilder<Source>, LiteralCommandNode<Source>>

Adds custom execution logic to this command. DEPRECATED Use runs instead.

Link copied to clipboard
open override fun toBrigadier(context: CommandBuildContext): List<LiteralCommandNode<Source>>

Converts this Kotlin command builder abstraction to an ArgumentBuilder of Brigadier.