CommandCreator

class CommandCreator<T : ArgumentBuilder<CommandSourceStack, T>>(var builder: T)

Creates and manages Minecraft commands using a DSL-style builder pattern.

This class wraps a Brigadier ArgumentBuilder and provides a Kotlin-friendly DSL for defining command structures, including literals, arguments, requirements, and execution logic.

Parameters

T

the type of Brigadier ArgumentBuilder being wrapped

Constructors

Link copied to clipboard
constructor(builder: T)

Properties

Link copied to clipboard
var builder: T

the underlying Brigadier ArgumentBuilder

Functions

Link copied to clipboard
fun aliases(vararg aliases: String, creator: CommandCreator<LiteralArgumentBuilder<CommandSourceStack>>.() -> Unit = {}): CommandCreator<T>

Adds multiple literal aliases to the command that all execute the same block.

Link copied to clipboard
fun <V> argument(name: String, type: ArgumentType<V>, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, V>>.() -> Unit = {}): CommandCreator<T>

Adds a required argument to the command.

Link copied to clipboard
fun blockPos(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a block position argument to the command.

Link copied to clipboard
fun boolean(name: String, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, Boolean>>.() -> Unit = {}): CommandCreator<T>

Adds a boolean argument to the command.

Link copied to clipboard
fun <V> CommandCreator<*>.custom(name: String, type: ArgumentType<V>, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, V>>.() -> Unit = {}): CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>

Registers a custom argument type to the DSL.

Link copied to clipboard
fun double(name: String, min: Double = -Double.MAX_VALUE, max: Double = Double.MAX_VALUE, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, Double>>.() -> Unit = {}): CommandCreator<T>

Adds a double argument to the command.

Link copied to clipboard
fun entities(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an entities argument to the command.

Link copied to clipboard
fun entity(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an entity argument to the command.

Link copied to clipboard
infix fun executes(block: (CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>

Sets the execution handler for this command.

Link copied to clipboard
fun executesConsole(block: (ConsoleCommandSender, CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>

Sets the execution handler for this command, limited to console only.

Link copied to clipboard
fun executesPlayer(block: (Player, CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>

Sets the execution handler for this command, limited to players only.

Link copied to clipboard
fun finePos(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a fine position argument (with decimals) to the command.

Link copied to clipboard
fun float(name: String, min: Float = -Float.MAX_VALUE, max: Float = Float.MAX_VALUE, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, Float>>.() -> Unit = {}): CommandCreator<T>

Adds a float argument to the command.

Link copied to clipboard
fun greedyString(name: String, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, String>>.() -> Unit = {}): CommandCreator<T>

Adds a greedy string argument to the command.

Link copied to clipboard
fun CommandContext<CommandSourceStack>.guard(condition: Boolean, errorMessage: ComponentBuilder.() -> Unit, block: () -> Int): Int

Guards the command execution with a condition. If the condition is false, sends an error message and returns 0.

Link copied to clipboard
fun integer(name: String, min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, Int>>.() -> Unit = {}): CommandCreator<T>

Adds an integer argument to the command.

Link copied to clipboard
infix inline operator fun String.invoke(creator: CommandCreator<LiteralArgumentBuilder<CommandSourceStack>>.() -> Unit): String

DSL operator to add a literal subcommand to the command.

Link copied to clipboard
infix fun literal(literal: String): CommandCreator<T>
fun literal(literal: String, creator: CommandCreator<LiteralArgumentBuilder<CommandSourceStack>>.() -> Unit = {}): CommandCreator<T>

Adds a literal argument to the command.

Link copied to clipboard
fun long(name: String, min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, Long>>.() -> Unit = {}): CommandCreator<T>

Adds a long argument to the command.

Link copied to clipboard
fun multipleEntities(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a multiple entities argument to the command.

Link copied to clipboard
fun multiplePlayers(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a multiple players argument to the command.

Link copied to clipboard
infix fun permission(permission: String): CommandCreator<T>

Sets a permission requirement for this command.

Link copied to clipboard
fun permissionAnd(permission: String, predicate: (CommandSourceStack) -> Boolean): CommandCreator<T>

Sets a permission requirement combined with an additional condition for this command.

Link copied to clipboard
fun player(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a player argument to the command.

Link copied to clipboard
fun players(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a players argument to the command.

Link copied to clipboard
fun register(plugin: Plugin)

Registers this command with the given plugin.

Link copied to clipboard

Sets a requirement that the command sender must be an operator.

Link copied to clipboard
fun requireOpAnd(predicate: (CommandSourceStack) -> Boolean): CommandCreator<T>

Sets a requirement that the command sender must be an operator and satisfy an additional condition.

Link copied to clipboard
infix fun requires(predicate: (CommandSourceStack) -> Boolean): CommandCreator<T>

Sets a requirement predicate for this command.

Link copied to clipboard
fun rotation(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a rotation argument (yaw and pitch) to the command.

Link copied to clipboard
fun CommandContext<CommandSourceStack>.sendError(consumer: ComponentBuilder.() -> Unit)

Sends an error message to the command sender.

Link copied to clipboard
fun CommandContext<CommandSourceStack>.sendMessage(consumer: ComponentBuilder.() -> Unit)

Sends a message to the command sender using Adventure component DSL.

fun CommandContext<CommandSourceStack>.sendMessage(component: Component)

Sends a message to the command sender.

Link copied to clipboard
fun CommandContext<CommandSourceStack>.sendSuccess(consumer: ComponentBuilder.() -> Unit)

Sends a success message to the command sender.

Link copied to clipboard
fun singleEntity(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a single entity argument to the command.

Link copied to clipboard
fun singlePlayer(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a single player argument to the command.

Link copied to clipboard
fun string(name: String, type: StringArgumentType = StringArgumentType.string(), creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, String>>.() -> Unit = {}): CommandCreator<T>

Adds a string argument to the command.

Link copied to clipboard
fun sub(name: String, creator: CommandCreator<LiteralArgumentBuilder<CommandSourceStack>>.() -> Unit): CommandCreator<T>

Adds a sub-command structure defined by a literal.

Link copied to clipboard
fun subcommand(name: String, creator: CommandCreator<LiteralArgumentBuilder<CommandSourceStack>>.() -> Unit = {}): CommandCreator<T>

Adds a subcommand to this command.

Link copied to clipboard
inline fun <E : Enum<E>> suggestion(): CommandCreator<T>

Adds static suggestions for this command argument from an Enum.

fun suggestion(provider: SuggestionProvider<CommandSourceStack>): CommandCreator<T>

Adds dynamic suggestions for this command argument.

fun suggestion(suggestions: List<String>): CommandCreator<T>

Adds static suggestions for this command argument.

Link copied to clipboard
fun suggestionAsync(provider: (CommandContext<CommandSourceStack>) -> List<String>): CommandCreator<T>

Adds asynchronous suggestions for this command argument.

Link copied to clipboard
fun word(name: String, creator: CommandCreator<RequiredArgumentBuilder<CommandSourceStack, String>>.() -> Unit = {}): CommandCreator<T>

Adds a word argument to the command.

Link copied to clipboard
fun world(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a world argument to the command.