Skip to content
On this page
Common

ClientDataApi

top.katton.apicommon/src/main/kotlin/top/katton/api/ClientDataApi.kt
Sync a key-value pair to all connected players. A value of `null` removes the key on the client side.

syncClientData

syncClientDataCommonFunction
kotlin
fun syncClientData(key: String, value: Any?)

Sync a key-value pair to all connected players. A value of null removes the key on the client side.

syncClientData

syncClientDataCommonFunction
kotlin
fun syncClientData(player: ServerPlayer, key: String, value: Any?)

Sync a key-value pair to a specific player. A value of null removes the key on the client side.

syncClientData

syncClientDataCommonFunction
kotlin
fun syncClientData(entries: Map<String, Any?>)

Sync multiple key-value pairs to all connected players. Entries with null values remove the key on the client side.

syncClientData

syncClientDataCommonFunction
kotlin
fun syncClientData(player: ServerPlayer, entries: Map<String, Any?>)

Sync multiple key-value pairs to a specific player. Entries with null values remove the key on the client side.

KattonClientData

KattonClientDataCommonObject
kotlin
object KattonClientData

Client-side accessor for server-synced data.

KattonClientData.get

KattonClientData.getCommonFunction
kotlin
operator fun get(key: String): Any?

Get the raw value by key. Returns null if key not found.

KattonClientData.getString

KattonClientData.getStringCommonFunction
kotlin
fun getString(key: String, default: String = ""): String

Get a string value with an optional default.

KattonClientData.getNumber

KattonClientData.getNumberCommonFunction
kotlin
fun getNumber(key: String, default: Number = 0): Number

Get a numeric value with an optional default.

KattonClientData.getBool

KattonClientData.getBoolCommonFunction
kotlin
fun getBool(key: String, default: Boolean = false): Boolean

Get a boolean value with an optional default.

KattonClientData.all

KattonClientData.allCommonFunction
kotlin
fun all(): Map<String, Any?>

Returns all synced data entries (read-only snapshot).

clientData

clientDataCommonProperty
kotlin
val clientData: KattonClientData

Shorthand accessor — use clientData["key"] in client scripts.