CommandContext

data class CommandContext(val sender: CommandSender, val label: String, val args: List<String>)

Represents the context of a command execution.

This class encapsulates the sender of the command, the label used to invoke the command, and the args passed to the command. It is used to pass necessary information to command handlers and to manage the execution flow.

Constructors

Link copied to clipboard
constructor(sender: CommandSender, label: String, args: List<String>)

Properties

Link copied to clipboard

The arguments passed to the command.

Link copied to clipboard

The label of the command used to invoke it.

Link copied to clipboard
val sender: CommandSender

The sender of the command (typically a Player or ConsoleCommandSender).

Functions

Link copied to clipboard
inline fun <T : Any> CommandContext.arg(index: Int): T

Inline extension function for CommandContext that retrieves and parses the argument at the specified index.

fun <T : Any> CommandContext.arg(index: Int, type: KClass<T>): T

Extension function for CommandContext that retrieves and parses the argument at the specified index.

Link copied to clipboard
inline fun <T : Any> CommandContext.argOrDefault(index: Int, default: T): T

Inline extension function for CommandContext that retrieves and parses the argument at the specified index, or returns a default value if the argument is missing.

fun <T : Any> CommandContext.argOrDefault(index: Int, type: KClass<T>, default: T): T

Extension function for CommandContext that retrieves and parses the argument at the specified index, or returns a default value if the argument is missing.

Link copied to clipboard
inline fun <T : Any> CommandContext.argOrNull(index: Int): T?

Inline extension function for CommandContext that retrieves and parses the argument at the specified index, or returns null if the argument is missing.

fun <T : Any> CommandContext.argOrNull(index: Int, type: KClass<T>): T?

Extension function for CommandContext that retrieves and parses the argument at the specified index, or returns null if the argument is missing.

Link copied to clipboard

Extension function for CommandContext that ensures the sender is a player.