Skip to content
On this page
Common

KattonConfigApi

top.katton.apicommon/src/main/kotlin/top/katton/api/KattonConfigApi.kt
Script-facing config API. Reads config values from the current script's pack manifest.

KattonConfig

KattonConfigCommonObject
kotlin
object KattonConfig

Script-facing config API. Reads config values from the current script's pack manifest.

Usage in scripts:

kotlin
import top.katton.api.*

val rate = config.getNumber("spawn_rate").toDouble()
val prefix = config.getString("message_prefix", "[Default]")
val debug = config.getBool("debug_mode")
val raw = config["some_key"]

Each script pack has its own independent config values (from manifest.json "config" field). The current pack is auto-detected from the script execution context.

KattonConfig.get

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

Get the raw config value by key. Returns null if key not found or pack not resolved.

KattonConfig.getString

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

Get a string config value with an optional default.

KattonConfig.getNumber

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

Get a numeric config value with an optional default.

KattonConfig.getBool

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

Get a boolean config value with an optional default.

KattonConfig.all

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

Returns all config entries for the current pack.

config

configCommonProperty
kotlin
val config: KattonConfig

Shorthand accessor — use config["key"] in scripts.