aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/gui/config/ManagedOption.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-23 23:02:08 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-23 23:02:08 +0100
commit656958937fe29da90d7229b979996a68b5ea5b67 (patch)
tree20396137c6f933194cc8cc612f08d3b35dce0094 /src/main/kotlin/gui/config/ManagedOption.kt
parent22bc3adbae747ef00e679458b0d407df31a9079b (diff)
downloadFirmament-656958937fe29da90d7229b979996a68b5ea5b67.tar.gz
Firmament-656958937fe29da90d7229b979996a68b5ea5b67.tar.bz2
Firmament-656958937fe29da90d7229b979996a68b5ea5b67.zip
feat: Add /dh command
Diffstat (limited to 'src/main/kotlin/gui/config/ManagedOption.kt')
-rw-r--r--src/main/kotlin/gui/config/ManagedOption.kt9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/kotlin/gui/config/ManagedOption.kt b/src/main/kotlin/gui/config/ManagedOption.kt
index d1aba83..383f392 100644
--- a/src/main/kotlin/gui/config/ManagedOption.kt
+++ b/src/main/kotlin/gui/config/ManagedOption.kt
@@ -6,7 +6,6 @@ import kotlinx.serialization.json.JsonObject
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
import net.minecraft.text.Text
-import moe.nea.firmament.Firmament
import moe.nea.firmament.util.ErrorUtil
class ManagedOption<T : Any>(
@@ -28,7 +27,13 @@ class ManagedOption<T : Any>(
val descriptionTranslationKey = "firmament.config.${element.name}.${propertyName}.description"
val labelDescription: Text = Text.translatable(descriptionTranslationKey)
- lateinit var value: T
+ private var actualValue: T? = null
+ var value: T
+ get() = actualValue ?: error("Lateinit variable not initialized")
+ set(value) {
+ actualValue = value
+ element.onChange(this)
+ }
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
this.value = value