aboutsummaryrefslogtreecommitdiff
path: root/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt')
-rw-r--r--src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt b/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
index 2bc5cd4..f0e9aa4 100644
--- a/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
+++ b/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
@@ -2,6 +2,7 @@ package moe.nea.firmament.compat.moulconfig
import io.github.notenoughupdates.moulconfig.Config
import moe.nea.firmament.gui.config.ManagedOption
+import moe.nea.firmament.util.ErrorUtil
abstract class ProcessedEditableOptionFirm<T : Any>(
val managedOption: ManagedOption<T>,
@@ -21,6 +22,22 @@ abstract class ProcessedEditableOptionFirm<T : Any>(
return managedOption.labelDescription.string
}
+ abstract fun fromT(t: T): Any
+ abstract fun toT(any: Any?): T?
+
+ final override fun get(): Any {
+ return fromT(managedOption.value)
+ }
+
+ final override fun set(p0: Any?): Boolean {
+ managedOption.value = toT(p0) ?: run {
+ ErrorUtil.softError("Failed to set value p0 in $this")
+ return false
+ }
+ managedConfig.save()
+ return true
+ }
+
override fun explicitNotifyChange() {
managedConfig.save()
}