guard

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.

Return

1 if successful, 0 otherwise

Parameters

condition

the condition to check

errorMessage

the error message to send if condition is false

block

the code to execute if condition is true