Skip to content
On this page

Common

KattonServerApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonServerApi.kt
Access to all online players.

players

CommonProperty
kotlin
val players: KattonPlayerList

Access to all online players.

entities

CommonProperty
kotlin
val entities: KattonServerEntityCollection

Access to all entities across all levels.

storage

CommonProperty
kotlin
val storage: CommandStorage

Server command storage for persistent data.

scoreboard

CommonProperty
kotlin
val scoreboard: Scoreboard

Server scoreboard instance.

difficulty

CommonProperty
kotlin
var difficulty: Difficulty

Current server difficulty setting.

execute

CommonFunction
kotlin
fun execute(command: String)

Execute a command string.

Parameters

ParameterDescription
commandthe command string to execute

executeCommand

CommonFunction
kotlin
fun executeCommand(source: CommandSourceStack, command: String)

Execute a command as the provided command source.

Parameters

ParameterDescription
sourcethe command source to run the command as
commandthe command string to execute

executeCommandAsServer

CommonFunction
kotlin
fun executeCommandAsServer(command: String)

Execute a command as the server console.

Parameters

ParameterDescription
commandthe command string to execute

findPlayer

CommonFunction
kotlin
fun findPlayer(player: String): ServerPlayer?

Find a player by name.

Parameters

ParameterDescription
playerthe player name to search for

Returns

the ServerPlayer if found, null otherwise

findPlayer

CommonFunction
kotlin
fun findPlayer(uuid: UUID): ServerPlayer?

Find a player by UUID.

Parameters

ParameterDescription
uuidthe player UUID to search for

Returns

the ServerPlayer if found, null otherwise

findEntities

CommonFunction
kotlin
fun findEntities(level: ServerLevel, selector: EntitySelector): List<Entity>

Find entities using an entity selector in a level.

Parameters

ParameterDescription
levelthe ServerLevel to search in
selectorthe EntitySelector to use

Returns

list of matching entities

findEntity

CommonFunction
kotlin
fun findEntity(uuid: UUID): Entity?

Find an entity by UUID across all levels.

Parameters

ParameterDescription
uuidthe entity UUID to search for

Returns

the Entity if found, null otherwise

ban

CommonFunction
kotlin
fun ban(player: ServerPlayer)

Ban a player by adding them to the server ban list and disconnecting them.

Parameters

ParameterDescription
playerthe ServerPlayer to ban

banIp

CommonFunction
kotlin
fun banIp(ip: String)

Ban an IP address and disconnect matching players.

Parameters

ParameterDescription
ipIP address string to ban

deop

CommonFunction
kotlin
fun deop(player: ServerPlayer)

De-op a player (remove operator status).

Parameters

ParameterDescription
playerServerPlayer to de-op

op

CommonFunction
kotlin
fun op(player: ServerPlayer)

Op a player (grant operator status).

Parameters

ParameterDescription
playerServerPlayer to op

setDifficulty

CommonFunction
kotlin
fun setDifficulty(difficulty: Difficulty, ignoreLock: Boolean = true)

Set server difficulty.

Parameters

ParameterDescription
difficultynew Difficulty
ignoreLockwhether to ignore difficulty lock

runFunction

CommonFunction
kotlin
fun runFunction(id: Identifier, source: CommandSourceStack = requireServer().createCommandSourceStack())

Run a function (data pack function) with an optional command source.

Parameters

ParameterDescription
idfunction identifier
sourcecommand source to use (defaults to server)

setGameMode

CommonFunction
kotlin
fun setGameMode(player: ServerPlayer, gameMode: GameType)

Set a player's game mode.

Parameters

ParameterDescription
playertarget ServerPlayer
gameModetarget GameType

getGameMode

CommonFunction
kotlin
fun getGameMode(player: ServerPlayer): GameType

Get a player's current GameType.

Parameters

ParameterDescription
playertarget ServerPlayer

Returns

current GameType

setGameRule

CommonFunction
kotlin
fun <T : Any> setGameRule(key: GameRule<T>, value: T)

Set a game rule value on the server overworld.

Parameters

ParameterDescription
keyGameRule key
valuevalue to set

getGameRule

CommonFunction
kotlin
fun <T : Any> getGameRule(key: GameRule<T>): T

Get a game rule value from the server overworld.

Parameters

ParameterDescription
keyGameRule key

Returns

value of the game rule

kick

CommonFunction
kotlin
fun kick(player: Player, reason: Component = Component.translatable("multiplayer.disconnect.kicked"))

Kick a player with an optional reason component.

Parameters

ParameterDescription
playertarget Player (ServerPlayer required to disconnect)
reasondisconnect reason component