Skip to content
On this page

Common

KattonPlayerApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonPlayerApi.kt
List-like access to all online players.

KattonPlayerList

CommonClass
kotlin
class KattonPlayerList( val playerList: PlayerList ) : List<ServerPlayer> by playerList.players

List-like access to all online players.

Properties

PropertyDescription
playerListThe underlying PlayerList

KattonPlayerList.get

CommonFunction
kotlin
operator fun get(name: String): ServerPlayer?

Find a player by name.

KattonPlayerList.get

CommonFunction
kotlin
operator fun get(uuid: UUID): ServerPlayer?

Find a player by UUID.

KattonLevelPlayerCollection

CommonClass
kotlin
class KattonLevelPlayerCollection( val level: ServerLevel ) : List<ServerPlayer> by level.players

Collection of players within a specific level.

Properties

PropertyDescription
levelThe ServerLevel containing the players

KattonLevelPlayerCollection.get

CommonFunction
kotlin
operator fun get(uuid: UUID): Player?

Find a player by UUID in this level.

addItem

CommonFunction
kotlin
fun Player.addItem(item: Item, amount: Int)

Add an item to a player's inventory.

Parameters

ParameterDescription
playerthe Player to receive the item
itemthe Item type to add
amountthe quantity to add

clearInventory

CommonFunction
kotlin
fun clearInventory(player: Player)

Clear a player's inventory.

Parameters

ParameterDescription
playerthe Player whose inventory will be cleared

setItem

CommonFunction
kotlin
fun setItem(player: Player, slot: Int, itemStack: ItemStack)

Set an item into a player's inventory slot.

Parameters

ParameterDescription
playerthe Player to modify
slotinventory slot index
itemStackitem stack to set

getItem

CommonFunction
kotlin
fun getItem(player: Player, slot: Int): ItemStack

Get the item from a player's inventory slot.

Parameters

ParameterDescription
playerthe Player to query
slotinventory slot index

Returns

ItemStack in the slot

giveItem

CommonFunction
kotlin
fun giveItem(player: Player, itemStack: ItemStack): Boolean

Try to give an item stack to a player.

Parameters

ParameterDescription
playerthe Player to receive the item
itemStackthe ItemStack to give

Returns

true if added to inventory, false if full

hasItem

CommonFunction
kotlin
fun hasItem(player: Player, item: Item): Boolean

Check if a player has a specific item type in their inventory.

Parameters

ParameterDescription
playerthe Player to check
itemthe Item type to search for

Returns

true if the player has the item, false otherwise

findItem

CommonFunction
kotlin
fun findItem(player: Player, item: Item): Int

Find the slot index of an item in player's inventory.

Parameters

ParameterDescription
playerthe Player to search
itemitem type to find

Returns

slot index or -1 if not found

removeItem

CommonFunction
kotlin
fun removeItem(player: Player, item: Item, count: Int): Boolean

Remove a count of items from player's inventory.

Parameters

ParameterDescription
playerthe Player to modify
itemitem type to remove
countamount to remove

Returns

true if removal succeeded, false otherwise

enchant

CommonFunction
kotlin
fun enchant(itemStack: ItemStack, enchantment: Holder<Enchantment>, level: Int)

Enchant an ItemStack with an enchantment.

Parameters

ParameterDescription
itemStacktarget ItemStack
enchantmentenchantment holder to apply
levelenchantment level

enchantMainHand

CommonFunction
kotlin
fun enchantMainHand(entity: LivingEntity, enchantment: Holder<Enchantment>, level: Int)

Enchant the item in an entity's main hand if present.

Parameters

ParameterDescription
entitytarget LivingEntity
enchantmentenchantment holder to apply
levelenchantment level

addXpPoints

CommonFunction
kotlin
fun addXpPoints(player: Player, points: Int)

Give experience points to a player.

Parameters

ParameterDescription
playertarget Player
pointsexperience points to add

addXpLevels

CommonFunction
kotlin
fun addXpLevels(player: Player, levels: Int)

Give experience levels to a player.

Parameters

ParameterDescription
playertarget Player
levelslevels to add

setXpLevel

CommonFunction
kotlin
fun setXpLevel(player: Player, level: Int)

Set a player's experience level.

Parameters

ParameterDescription
playertarget Player
levellevel value to set

getXpLevel

CommonFunction
kotlin
fun getXpLevel(player: Player): Int

Get a player's experience level.

Parameters

ParameterDescription
playertarget Player

Returns

current experience level

getXpProgress

CommonFunction
kotlin
fun getXpProgress(player: Player): Float

Get a player's experience progress (fraction).

Parameters

ParameterDescription
playertarget Player

Returns

experience progress as float (0..1)

spawnPoint

CommonFunction
kotlin
fun spawnPoint(player: MutableCollection<ServerPlayer>, level: ServerLevel, pos: BlockPos, rot: Vec2)

Set spawn point for a collection of players.

Parameters

ParameterDescription
playercollection of ServerPlayer to set
levelserver level for dimension
posrespawn position
rotrotation vector (pitch,x / yaw,y)

setWorldSpawn

CommonFunction
kotlin
fun setWorldSpawn(level: ServerLevel, blockPos: BlockPos, rot: Vec2)

Set the world spawn and respawn orientation for a level.

Parameters

ParameterDescription
levelserver level
blockPosspawn position
rotrotation vector (pitch,x / yaw,y)

spectate

CommonFunction
kotlin
fun spectate(player: ServerPlayer, target: Entity?): Boolean

Make a player spectate a target entity.

Parameters

ParameterDescription
playerspectator ServerPlayer
targetentity to spectate, or null to stop

Returns

true if spectation succeeded, false otherwise