event list & properties

these are the only valid event names. anything else in @Katton.listen("...") will error

player_join

fires when a player enters the arena (or their own preset world), NOT the same as connecting to the server

@Katton.listen("player_join")
function onJoin(event) {
    event.player.sendMessage("&aWelcome!")
}

properties: event.player

player_quit

fires when a player leaves the arena

@Katton.listen("player_quit")
function onQuit(event) {
    Katton.log.info(event.player.name + " left")
}

properties: event.player

player_death

@Katton.listen("player_death")
function onDeath(event) {
    for (player in Katton.players.all()) {
        player.sendMessage("&c" + event.player.name + " has died")
        event.clearDrops() // you can use this to clear the drops (if keep inv is off)
    }
}

properties: event.player & event.clearDrops()

player_respawn

@Katton.listen("player_respawn")
function onRespawn(event) {
    event.player.sendMessage("&around 2!!")
}

properties: event.player

player_interact

fires when you interact with a block like a chest

@Katton.listen("player_interact")
function onInteract(event) {
    if (event.action == "right_click_block") {
        event.player.sendMessage("&7you right clicked a " + event.block)
    }
}

properties: event.player, event.item, event.action, event.block

player_leftclick / player_rightclick

if you want to detect when a player left clicks or right clicks:

@Katton.listen("player_rightclick")
function onRightClick(event) {
    val item = event.item
    if (item != null && item.getTag("ability") == "leap_wand") {
        event.player.launchForward(horizontal = 1.8, vertical = 0.65)
        event.cancel()
    }
}

properties: event.player, event.item

block_break / block_place

@Katton.listen("block_break")
function onBreak(event) {
    if (event.block == "tnt") {
        event.cancel() // no breaking TNT
    }
}

@Katton.listen("block_place")
function onPlace(event) {
    Katton.log.info(event.player.name + " placed " + event.block) // only shows to you
}

properties: event.player, event.block

entity_death

fires for any entity dying, including players

@Katton.listen("entity_death")
function onEntityDeath(event) {
    if (event.entity == "zombie") {
        Katton.vars.script.increment("zombies_killed")
    }
}

properties: event.entity, event.killer

item_drop / item_pickup

@Katton.listen("item_drop")
function onDrop(event) {
    event.player.sendMessage("&7dropped: " + event.item)
}

@Katton.listen("item_pickup")
function onPickup(event) {
    event.player.sendMessage("&apicked up something!")
}

properties: event.player, event.item (both events)

player_interact_entity

fires when a player right clicks an entity

@Katton.listen("player_interact_entity")
function onEntityInteract(event) {
    if (event.entity == "villager") {
        event.player.sendMessage("&ethe villager hates u")
    }
}

properties: event.player, event.entity

projectile_hit

fires when a projectile hits either a block or a entity

@Katton.listen("projectile_hit")
function onProjectileHit(event) {
    val player = event.player // returns the player who owns the projectile
    val projectile = event.projectile // returns the type of projectile that it is like "arrow" as a string
    val entity = event.entity // returns the entity it hit as a string (returns null if it hits a block)
    val block = event.block // returns the block it hit as a string (returns null if it hits a entity)

    player.sendMessage("player: "+player.name + " | projectile: " +projectile + " | entity: " + entity + " | block: " + block)
}

properties: event.player, event.projectile, event.entity, event.block

player_shoot_bow

fires when a player shoots a bow

@Katton.listen("player_shoot_bow")
function onBowShoot(event) {
    val player = event.player // returns the player who shot the bow
    val item = event.item // returns the true item that was used
    val projectile = event.projectile // returns the projectile entity

    player.sendMessage("player: "+player.name + " | item: " +item.name + " | projectile: " + projectile)
}

properties: event.player, event.item, event.projectile

important!: event.block, event.entity and event.projectile are just strings

they are the lowercase type name (like: "stone", "zombie") not full objects. if you need to actually affect the block or entity itself, that has to happen through other means (see world)

event.item, on the other hand, is a full item value where you can call .getTag(...), .setName(...), etc. on it. see item.