argument

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

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

Parameters

name

the name of the argument - This will be displayed to the player, if there is enough room for the tooltip.

type

the type of the argument - There are predefined types like StringArgumentType.string() or IdentifierArgumentType.identifier(). You can also pass a lambda, as ArgumentType is a functional interface. For simple types, consider using the inline reified version of this function instead.


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

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

Parameters

name

the name of the argument - This will be displayed to the player, if there is enough room for the tooltip.

typeProvider

the provider for the ArgumentType - there are predefined types like BlockStateArgument.block(context) and ItemArgument.item(context) or you can pass your own


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

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).

Parameters

name

the name of the argument - This will be displayed to the player, if there is enough room for the tooltip.

parser

gives you a StringReader, which allows you to parse the input of the user - you should return a value of the given type T, which will be the argument value


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.

Parameters

name

the name of the argument - This will be displayed to the player, if there is enough room for the tooltip.