CommandCreator

class CommandCreator<T : ArgumentBuilder<CommandSourceStack, T>>(val plugin: Plugin?, 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.

Type Parameters

T

the type of Brigadier ArgumentBuilder being wrapped

Constructors

Link copied to clipboard
constructor(plugin: Plugin?, builder: T)

Properties

Link copied to clipboard
var builder: T

the underlying Brigadier ArgumentBuilder

Link copied to clipboard
val plugin: Plugin?

the plugin instance for launching coroutines

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 angle(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an angle argument to the command.

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 axes(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an axes argument (set of X/Y/Z axes) to the command.

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

Adds a block-in-world predicate 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 blockState(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a block state 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 columnBlockPos(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>
Link copied to clipboard
fun columnFinePos(name: String, centerIntegers: Boolean = false, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a column fine position argument (2D decimal coordinates) to the command.

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

Registers a custom argument type to the DSL.

Link copied to clipboard
fun double(name: String, min: Double = Double.MIN_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 doubleRange(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a double range 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
fun entityAnchor(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an entity anchor 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
infix fun executesConsoleSuspend(block: suspend (ConsoleCommandSender, CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>
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
infix fun executesPlayerSuspend(block: suspend (Player, CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>
Link copied to clipboard
infix fun executesSuspend(block: suspend (CommandContext<CommandSourceStack>) -> Int): CommandCreator<T>
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. Equivalent to finePos with centerIntegers = false.

fun finePos(name: String, centerIntegers: Boolean, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a fine position argument with centerIntegers option to the command.

Link copied to clipboard
fun float(name: String, min: Float = Float.MIN_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 gameMode(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>
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 heightMap(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a height map argument to the command.

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

Adds a hex color argument to the command.

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
fun integerRange(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an integer range 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
fun itemStack(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>
Link copied to clipboard
fun itemStackPredicate(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds an item stack predicate argument to the command.

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

Adds a key argument 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 namedColor(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a named color argument to the command.

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

Adds an objective criteria 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 playerProfiles(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a player profiles 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(description: String?, aliases: Collection<String>)

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
Link copied to clipboard
infix fun requires(predicate: (CommandSourceStack) -> Boolean): CommandCreator<T>

Sets a requirement predicate for this command.

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

Adds a resource argument to the command.

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

Adds a resource key argument to the 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 scoreboardDisplaySlot(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a scoreboard display slot argument 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 signedMessage(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a signed message argument to the command.

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

Adds a slots argument (multiple inventory slots) to the command.

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

Adds a string argument to the command.

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

Adds a style argument to the 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 team(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>
Link copied to clipboard
fun templateMirror(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>

Adds a template mirror argument to the command.

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

Adds a template rotation argument to the command.

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

Adds a time argument to the command.

Link copied to clipboard
fun uuid(name: String, creator: CommandCreator<out ArgumentBuilder<CommandSourceStack, *>>.() -> Unit = {}): CommandCreator<T>
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.