Package-level declarations

The dev.lyzev.api.setting package is a core component of the Kratos setting management library. It provides the necessary interfaces and classes to create and manage settings in your projects.

Usage Example

Setting

The Setting class is the base class for all settings. It provides the necessary functionality to create and manage settings.

class BooleanSetting(
container: KClass<*>, name: String, description: String?, value: Boolean, hide: () -> Boolean = { false }, change: (Boolean) -> Unit = {}
) : Setting<Boolean>(container, name, description, value, hide, change)

Setting Manager

The SettingManager class is responsible for managing settings. It provides the necessary functionality to create, register, and manage settings.

How to add a setting

SettingManager.settings += setting

Note: Settings are automatically registered when they are created. You do not need to manually register them.

How to get a setting

fun `test setting manager get by container class`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSettings = SettingManager[this::class]
}

fun `test setting manager get by container class and name`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSettings = SettingManager[this::class, "test"]
}

fun `test setting manager get by container class and type class`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSetting = SettingManager.get(this::class, BooleanSetting::class, "test")
}

fun `test setting manager get by container and type`() {
val setting = BooleanSetting(this::class, "test", true)
val retrievedSetting = SettingManager.get(
"dev.lyzev.api.setting.test.SettingTests",
"dev.lyzev.api.setting.test.BooleanSetting",
"test"
)
}

Types

Link copied to clipboard
abstract class Setting<T>(val container: KClass<*>, val name: String, val desc: String? = null, value: T, hidden: () -> Boolean = { false }, onChange: (T) -> Unit = {})

A generic abstract class representing a setting that can be used in a settings container.

Link copied to clipboard

Singleton object responsible for managing settings.