feat: Add /dh command
This commit is contained in:
@@ -15,7 +15,6 @@ import org.lwjgl.glfw.GLFW
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlin.enums.enumEntries
|
||||
import kotlin.io.path.createDirectories
|
||||
import kotlin.io.path.readText
|
||||
import kotlin.io.path.writeText
|
||||
@@ -135,7 +134,7 @@ abstract class ManagedConfig(
|
||||
return StringIdentifiable.createCodec { x() }
|
||||
}
|
||||
|
||||
// TODO: wait on https://youtrack.jetbrains.com/issue/KT-73434
|
||||
// TODO: wait on https://youtrack.jetbrains.com/issue/KT-73434
|
||||
// protected inline fun <reified E> choice(
|
||||
// propertyName: String,
|
||||
// noinline default: () -> E
|
||||
@@ -148,6 +147,8 @@ abstract class ManagedConfig(
|
||||
// default
|
||||
// )
|
||||
// }
|
||||
open fun onChange(option: ManagedOption<*>) {
|
||||
}
|
||||
|
||||
protected fun duration(
|
||||
propertyName: String,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user