aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 00:27:01 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 00:27:01 +0200
commita10c097974d0b476be275c1fd2888d7502508efd (patch)
treeb9059f9ff1d010ce7ee32c4aece25a5dbc4141c3 /src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
parent88bff6a920bd597e7ef2a22bbcd99750158e6816 (diff)
downloadskyhanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.gz
skyhanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.bz2
skyhanni-a10c097974d0b476be275c1fd2888d7502508efd.zip
added profile specific config support
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 292c87836..74e6f1461 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -1,17 +1,20 @@
package at.hannibal2.skyhanni.config
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import com.google.gson.GsonBuilder
+import com.google.gson.TypeAdapter
+import com.google.gson.stream.JsonReader
+import com.google.gson.stream.JsonWriter
import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory
import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis
import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver
import io.github.moulberry.moulconfig.processor.MoulConfigProcessor
import java.io.*
import java.nio.charset.StandardCharsets
+import java.util.*
import kotlin.concurrent.fixedRateTimer
class ConfigManager {
@@ -20,6 +23,16 @@ class ConfigManager {
.excludeFieldsWithoutExposeAnnotation()
.serializeSpecialFloatingPointValues()
.registerTypeAdapterFactory(PropertyTypeAdapterFactory())
+ .registerTypeAdapter(UUID::class.java, object : TypeAdapter<UUID>() {
+ override fun write(out: JsonWriter, value: UUID) {
+ out.value(value.toString())
+ }
+
+ override fun read(reader: JsonReader): UUID {
+ return UUID.fromString(reader.nextString())
+ }
+ }.nullSafe())
+ .enableComplexMapKeySerialization()
.create()
}
@@ -83,8 +96,6 @@ class ConfigManager {
saveConfig("blank config")
}
- ConfigLoadEvent().postAndCatch()
-
val features = SkyHanniMod.feature
processor = MoulConfigProcessor(SkyHanniMod.feature)
BuiltinMoulConfigGuis.addProcessors(processor)
@@ -116,6 +127,7 @@ class ConfigManager {
file.parentFile.mkdirs()
file.createNewFile()
BufferedWriter(OutputStreamWriter(FileOutputStream(file), StandardCharsets.UTF_8)).use { writer ->
+ // TODO remove old "hidden" area
writer.write(gson.toJson(SkyHanniMod.feature))
}
} catch (e: IOException) {