CommandContext

class CommandContext<T>(flyLib: FlyLib<T>, config: T?, command: Command<T>, sender: CommandSender, world: World?, server: Server, message: String, depth: Int, typedArgs: List<Any?>)

The context when the command is executed. It is passed as an argument or receiver when executing a command or completing a tab. This class holds information when executing a command or completing a tab, which can be retrieved by the plug-in that registered the command, the command itself, the sender of the command, etc. It can also send a message to the executor of the command, display usage instructions, etc.

Constructors

CommandContext
Link copied to clipboard
fun <T> CommandContext(flyLib: FlyLib<T>, config: T?, command: Command<T>, sender: CommandSender, world: World?, server: Server, message: String, depth: Int, typedArgs: List<Any?> = emptyList())

Functions

fail
Link copied to clipboard
fun fail(text: String)

send red string

message
Link copied to clipboard
fun message(builder: ComponentBuilderAction)

send component via builder

fun message(text: String)

send string message

fun message(component: Component)

send component

fun message(text: String, color: Color)

send string colored message

pluginMessage
Link copied to clipboard
fun pluginMessage(builder: ComponentBuilderAction)

send component via builder with plugin name

fun pluginMessage(text: String)

send string with plugin name

fun pluginMessage(component: Component)

send component with plugin name

fun pluginMessage(text: String, color: Color)

send colored string with plugin name

pluginMessageFail
Link copied to clipboard
fun pluginMessageFail(text: String)

send red string with plugin name

pluginMessageSuccess
Link copied to clipboard
fun pluginMessageSuccess(text: String)

send green string with plugin name

pluginMessageWarn
Link copied to clipboard
fun pluginMessageWarn(text: String)

send yellow string with plugin name

sendHelp
Link copied to clipboard
fun sendHelp()

Display the information of the command in this context in the sender of this context. (It will also include usages and examples.)

success
Link copied to clipboard
fun success(text: String)

send green string

updateConfig
Link copied to clipboard
fun updateConfig(action: T.() -> Unit)
warn
Link copied to clipboard
fun warn(text: String)

send yellow string

Properties

args
Link copied to clipboard
val args: List<String>

Command arguments. The remaining arguments except the beginning of the command are assigned. These are all returned as strings. If you need parsed values, see typedArgs.

command
Link copied to clipboard
val command: Command<T>

The command that has been executed or is about to be executed.

config
Link copied to clipboard
val config: T?
flyLib
Link copied to clipboard
val flyLib: FlyLib<T>
message
Link copied to clipboard
val message: String

Command input message. (includes slash)

player
Link copied to clipboard
val player: Player?

Executed command sender. (Limited to the player, but null if executed by someone other than the player.)

plugin
Link copied to clipboard
val plugin: JavaPlugin
sender
Link copied to clipboard
val sender: CommandSender

The executor of the command or the entity that is about to execute it (may not be the player).

server
Link copied to clipboard
val server: Server

The server on which the plugin was run

typedArgs
Link copied to clipboard
val typedArgs: List<Any?>
world
Link copied to clipboard
val world: World?

The world where the command was executed