Skip to content

Events, Commands, and Input

Override configureEvents:

override fun configureEvents(events: EventsScope) {
events.onPlayerMove {
if (!requireAlive()) return@onPlayerMove
if (to.y < 20) {
eliminateTrackedPlayer(player)
player.gameMode = GameModes.SPECTATOR
}
}
events.onEntityDamage {
if (!isRunning || !requireParticipant()) {
cancel()
}
}
}

Common context helpers:

  • requireParticipant() filters to players in the match.
  • requireAlive() filters to tracked alive players.
  • cancel() sets the normalized cancellation flag when the event supports it.
  • Event-specific helpers include clearDrops(), noDrops(), suppressDamage(), and removeProjectile().

Supported event families include:

HandlerUse case
onBlockBreak, onBlockPlaceBuild/break rules, no-drop arenas, protected regions.
onPlayerMoveVoid checks, areas, parkour checkpoints, freeze phases.
onPlayerDeath, onPlayerQuitLives, elimination, cleanup, early ending.
onEntityDamage, onEntityDamageByEntityCombat rules, friendly fire, custom damage, shields.
onPlayerInteract, onEntityInteractWeapons, abilities, menus, objectives.
onProjectileLaunch, onProjectileHitBlockProjectile metadata, block effects, hit cleanup.
onCraftPrepare, onCraftItem, onInventoryOpenCrafting rules and inventory restrictions.
onToggleFlightDouble-jump style mechanics and flight prevention.
onItemRightClick, onItemDrop, etc.Interactive item definitions from ItemDSL.

Use the generic escape hatch for custom normalized events:

events.on(MyCustomEvent::class) {
// event is typed as MyCustomEvent
}
override fun configureCommands(commands: GameCommandsScope) {
commands.command("give-token") {
description = "Give a player a token."
argument("target", GameInputTypes.player())
argument("amount", GameInputTypes.integer(min = 1, max = 64), optional = true, default = 1)
executes {
val target = arg<GamePlayer>("target")
val amount = arg<Int>("amount")
repeat(amount) {
target.inventory.add(ItemDSL("emerald") { name = "<green>Token" })
}
}
}
}

Arguments are parsed in order. A greedy text argument must be last.

Built-in GameInputTypes:

TypeParses
text(minLength, maxLength)Greedy free text.
word()A single no-whitespace token.
integer(min, max)Whole numbers.
number(min, max)Doubles.
bool()true/false, yes/no, enabled/disabled, 1/0.
player()Online player lookup through the platform adapter.
itemName()Platform-known or syntactically valid item names.

The same input types power chat prompts:

prompt(
player = player,
type = GameInputTypes.itemName(),
message = "<yellow>Type an item id.",
allowCancel = true,
cancelWords = setOf("cancel", "stop"),
) { respondent, itemId ->
respondent.inventory.add(ItemDSL(itemId))
}

Prompt state is per-player and per-game. If lockMovement = true, the runtime blocks movement and reminds the player to answer.