aboutsummaryrefslogtreecommitdiff
path: root/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-17 17:45:29 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-17 17:45:29 +0100
commite00c21b2ade870c94b2641d24bf75ca15f81b044 (patch)
treecdf8e5564027891ad62b299aaf1b71628af75b9d /src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt
parent7c4205a07cd720af7660672c129607d2dcf1b1e7 (diff)
downloadFirmament-e00c21b2ade870c94b2641d24bf75ca15f81b044.tar.gz
Firmament-e00c21b2ade870c94b2641d24bf75ca15f81b044.tar.bz2
Firmament-e00c21b2ade870c94b2641d24bf75ca15f81b044.zip
fix: MoulConfig options sometimes not saving
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()
}