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 //player name
player.uuid //player uuid as a string
player.type //entity type name
player.world //current world name
player.location //player location object
player.health //player health
player.game_mode //player game mode
player.velocity //player velocity object
player.vehicle //a `entity` value for whatever they are riding
player.is_sneaking //true / false
player.is_sprinting //true / false
player.facing //tells you which direction the player is looking, as a number: 1 (down), 2 (up), 3 (north), 4 (south), 5 (west), 6 (east)
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.is_blocking //whether the player is blocking
methods
player.setArmor(slot, item)
player.getArmor(slot)
player.countItem(material)
player.setGamemode(gamemode)
player.setHealth(health)
player.sendMessage(text)
player.sendTitle(title, subtitle = "")
player.setCompassTarget(location)
player.sendActionBar(text)
player.teleport(location)
player.give(item)
player.setTool(item)
player.setOffhandTool(item)
player.playSound(sound, volume = 1.0, pitch = 1.0)
player.launchForward(horizontal = 1.8, vertical = 0.65)
player.setVelocity(x, y, z)
player.giveEffect(Katton.potionEffect(potion_effect, time, strength))
player.removeEffect(potion_effect)
player.removeAllEffects()
player.clearInventory()
player.setGlowing(glowing = true)
player.setMovementSpeed(speed)
player.resetMovementSpeed()
player.setJumpStrength(strength)
player.resetJumpStrength()
player.setScale(scale)
player.resetScale()
player.setInvulnerable(invulnerable = true)
player.mount(entity)
player.dismount()
player.shootProjectile(projectile = "arrow", speed = 2.0)
setArmor
sets an item to the player's armor slot
player.setArmor(slot, item)
Note
the avialable armor slots are: head/helmet, chest/chestplate, legs/leggings, feet/boots
example
val helmet = Katton.item("diamond_helmet")
player.setArmor("head", helmet)
getArmor
gets the item in the specified armor slot
player.getArmor(slot)
example
val helmet = player.getArmor("head")
countItem
number of that material in inventory (incl. armor/offhand)
player.countItem(material)
example
val count = player.countItem("diamond")
setGamemode
changes a player gamemode
player.setGamemode(gamemode)
Note
survival/adventure sets them to survival if placing/breaking/building is on, if not it sets them to adventure
example
player.setGamemode("creative") // caps doesn't matter
setHealth
sets the player's current health
player.setHealth(health)
example
player.setHealth(5)
sendMessage
sends a chat message to the player
player.sendMessage(text)
example
player.sendMessage("&awelcome!")
sendTitle
displays a optional title and optional subtitle on the player's screen
player.sendTitle(title, subtitle = "")
example
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 top and Round starting on bottom
setCompassTarget
sets the target location for the player's compass
player.setCompassTarget(location)
example
player.setCompassTarget({ "x": 100, "y": 64, "z": 200 })
sendActionBar
displays text above the player's hotbar
player.sendActionBar(text)
example
player.sendActionBar("&emoooooo") // shows moooooo in yellow on the actionbar
teleport
teleports the player to a target location object
player.teleport(location)
example
player.teleport({ "x": 100, "y": 50, "z": 150, "yaw": 0, "pitch": 0 })
give
adds an item to the player's inventory
player.give(item)
Note
see item for making items
example
val sword = Katton.item("diamond_sword")
player.give(sword)
setTool
replaces whatever item is currently held in that hand slot
player.setTool(item)
Note
replaces whatever's currently in that hand, it doesn't add to the inventory like give does
example
player.setTool(Katton.item("diamond_sword"))
setOffhandTool
replaces whatever item is currently held in that hand slot
player.setOffhandTool(item)
Note
replaces whatever's currently in that hand, it doesn't add to the inventory like give does
example
player.setOffhandTool(Katton.item("shield"))
playSound
plays a sound effect directly to the player
player.playSound(sound, volume = 1.0, pitch = 1.0)
Note
you can find all valid sound names at: https://jd.papermc.io/paper/1.21.11/org/bukkit/Sound.html
example
player.playSound("entity_experience_orb_pickup")
player.playSound("entity_experience_orb_pickup", 0.5, 1.5)
launchForward
launches the player in the direction they are currently facing
player.launchForward(horizontal = 1.8, vertical = 0.65)
Note
maximum value for both horizontal and vertical speed is 6.0
example
player.launchForward(1.8, 0.65)
setVelocity
sets the player's velocity
player.setVelocity(x, y, z)
example
player.setVelocity(0.5, 2, 1)
giveEffect
gives the player a potion effect
player.giveEffect(Katton.potionEffect(potion_effect, time, strength))
example
player.giveEffect(Katton.potionEffect("speed", 10.seconds, 2))
removeEffect
removes a specific potion effect from the player
player.removeEffect(potion_effect)
example
player.removeEffect("speed")
player.removeEffect(Katton.potionEffect("speed"))
removeAllEffects
removes all active potion effects from a player
player.removeAllEffects()
clearInventory
wipes the player's entire inventory
player.clearInventory()
Note
wipes everything, including equipped armor and offhand slots
example
player.clearInventory()
setGlowing
enables or disables the vanilla outline glowing effect around the player
player.setGlowing(glowing = true)
example
player.setGlowing(true)
player.setGlowing(false)
setMovementSpeed
modifies or resets the player's walking movement speed attribute
player.setMovementSpeed(speed)
example
player.setMovementSpeed(0.3) // vanilla default is 0.1
resetMovementSpeed
modifies or resets the player's walking movement speed attribute
player.resetMovementSpeed()
example
player.resetMovementSpeed() // back to 0.1
setJumpStrength
modifies or resets the player's jump height attribute
player.setJumpStrength(strength)
example
player.setJumpStrength(0.6) // vanilla default is 0.42
resetJumpStrength
modifies or resets the player's jump height attribute
player.resetJumpStrength()
example
player.resetJumpStrength() // back to 0.42
setScale
modifies the player's scale attribute
player.setScale(scale)
resetScale
resets the player's scale attribute to 1.0
player.resetScale()
setInvulnerable
toggles godmode damage immunity for the player
player.setInvulnerable(invulnerable = true)
example
player.setInvulnerable(true) // immune to all damage
player.setInvulnerable(false)
mount
makes the player mount a entity
player.mount(entity)
dismount
makes the player stop riding whatever they are currently riding
player.dismount()
example
player.dismount()
shootProjectile
shoots a projectile from the player in the direction they are currently facing
player.shootProjectile(projectile = "arrow", speed = 2.0)
Note
maximum speed value is 6.0
example
player.shootProjectile("arrow", 2.0)