player

you get a player value from Katton.players.* selectors, the sender parameter in a command handler, or event.player in an event handler

properties

player.name // "Steve"
player.uuid // "8667ba71-b85a-4004-af54-457a9734eed7" as a string
player.world // "customarena"
player.location // { x: 12.5, y: 64.0, z: -3.0, yaw: 90.0, pitch: 0.0 }
player.health // 20.0
player.game_mode // "survival" | "creative" | "adventure" | "spectator"
player.is_sneaking // true / false
player.is_sprinting // true / false
player.facing // 1-6, see below
player.tool // an `item` value for whatever's in their main hand (empty hand still gives you an item value, just air)
player.offhand_tool // same, but their off hand

player.facing

tells you which direction the player is looking, as a number:

value direction
1 down
2 up
3 north
4 south
5 west
6 east
@Katton.listen("player_leftclick")
function onLeftClick(event) {
    when (event.player.facing) {
        2 -> { event.player.sendMessage("&7you're looking up") }
        1 -> { event.player.sendMessage("&7you're looking down") }
        else -> { event.player.sendMessage("&7you're looking sideways") }
    }
}

up/down is only reported when the player is looking mostly straight up or down, otherwise you get whichever cardinal direction (N/S/E/W) they're mostly facing

methods

player.sendMessage(text)
player.sendTitle(title, subtitle = "")
player.sendActionBar(text)
player.teleport(location)
player.give(item)
player.playSound(sound, volume = 1, pitch = 1)
player.launchForward(horizontal, vertical)
player.shootProjectile(projectile, speed)
player.setTool(item)
player.setOffhandTool(item)
player.clearInventory()
player.setGlowing(glowing = true)
player.setMovementSpeed(speed)
player.resetMovementSpeed()
player.setJumpStrength(strength)
player.resetJumpStrength()
player.setInvulnerable(invulnerable = true)

sendMessage

player.sendMessage("&awelcome!")

supports & color codes

sendTitle

player.sendTitle("&cRED", "") // shows RED in red on the top line and nothing on the bottom
player.sendTitle("&eGet Ready!", "&7Round starting...") // shows Get Ready! in yellow on the top and Round starting on the bottom

sendActionBar

player.sendActionBar("&emoooooo") // shows moooooo in yellow on the actionbar

teleport

player.teleport({ "x": 100, "y": 50, "z": 150, "yaw": 0, "pitch": 0 }) // teleport to a location value

give

val sword = Katton.item("diamond_sword")
player.give(sword)

see item for making items

playSound

player.playSound("entity_experience_orb_pickup")
player.playSound("entity_experience_orb_pickup", volume = 0.5, pitch = 1.5)

launchForward

player.launchForward(horizontal = 1.8, vertical = 0.65)

launches the player in the direction theyre currently facing. horizontal is forward speed, vertical is upward speed. the max value is 6

shootProjectile

player.shootProjectile(projectile = "arrow", speed = 2)

shoots a projectile from player in the direction theyre currently facing. projectile is the projectile that is shot, speed is the speed the projectile has. the only projectiles that are able to be shot are:

list of allowed projectiles  
arrow spectral_arrow
snowball egg
ender_pearl fireball
ghast_fireball small_fireball
dragon_fireball wither_skull
shulker_bullet trident
experience_bottle  

the max speed value is 6

setTool / setOffhandTool

player.setTool(Katton.item("diamond_sword"))
player.setOffhandTool(Katton.item("shield"))

replaces whatever's currently in that hand, it doesn't add to the inventory like give does

clearInventory

player.clearInventory()

wipes their entire inventory, including armor and both hands

setGlowing

player.setGlowing(true)
player.setGlowing(false)

setMovementSpeed / resetMovementSpeed

player.setMovementSpeed(0.3) // vanilla default is 0.1
player.resetMovementSpeed() // back to 0.1

setJumpStrength / resetJumpStrength

player.setJumpStrength(0.6) // vanilla default is 0.42
player.resetJumpStrength() // back to 0.42

setInvulnerable

player.setInvulnerable(true) // immune to all damage
player.setInvulnerable(false)