DSL Command Arguments

All available arguments:

Using: function(index_of_argument) in simpleCommand or executor of SubCommand

Function
Description

argument

Null if argument not found or string

string

string or send error to sender

stringOrNull

same with argument

integer

integer or send error to sender

integerOrNull

Null if argument not found or integer

double

double or send error to sender

doubleOrNull

Null if argument not found or double

material

material or send error to sender

materialOrNull

Null if argument not found or material

world

world or send error to sender

worldOrNull

Null if argument not found or world

player

player or send error to sender

playerOrNull

Null if argument not found or player

offlinePlayer

offlinePlayer or send error to sender

Custom type

Also you can create your own type:

fun ExecutorContext.uuidOrNull(index: Int): UUID? = try { 
    UUID.fromString(argument(index)) 
    } catch(e: NullPointerException) {
        throw TypeParseException()
    }

Use argument(index) for get command argument as String?

If you need to send message if parse of type was failed, throw CommandExecuteException with one argument - tag of message

For example:

fun ExecutorContext.world(index: Int): World =
    worldOrNull(index) ?: run {
        throw CommandExecuteException("#no-such-world")
    }

Last updated