diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-09-07 19:59:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 19:59:58 +0200 |
commit | 83d48c6aeee1656c5a6966839a1951e67fccbc53 (patch) | |
tree | a2c94427ba09763f36cb495ea91ffc4111ab322b /src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt | |
parent | 4663ebc4c9d5ef6ed890eced49d90dd8e3589fb5 (diff) | |
download | skyhanni-83d48c6aeee1656c5a6966839a1951e67fccbc53.tar.gz skyhanni-83d48c6aeee1656c5a6966839a1951e67fccbc53.tar.bz2 skyhanni-83d48c6aeee1656c5a6966839a1951e67fccbc53.zip |
Feature: Display Tab Widgets (#1276)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index db70f7e89..4ac3f7925 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.core.config.Position +import at.hannibal2.skyhanni.config.core.config.PositionList import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson @@ -39,7 +40,6 @@ import java.nio.file.StandardCopyOption import java.util.EnumMap import kotlin.concurrent.fixedRateTimer import kotlin.reflect.KMutableProperty0 -import kotlin.reflect.KMutableProperty1 private fun GsonBuilder.registerIfBeta(create: TypeAdapterFactory): GsonBuilder { return if (LorenzUtils.isBetaVersion()) { @@ -66,8 +66,7 @@ class ConfigManager { private fun setConfigHolder(type: ConfigFileType, value: Any) { require(value.javaClass == type.clazz) - @Suppress("UNCHECKED_CAST") - (type.property as KMutableProperty0<Any>).set(value) + @Suppress("UNCHECKED_CAST") (type.property as KMutableProperty0<Any>).set(value) (jsonHolder as MutableMap<ConfigFileType, Any>)[type] = value } @@ -96,8 +95,7 @@ class ConfigManager { try { findPositionLinks(features, mutableSetOf()) } catch (e: Exception) { - if (LorenzEvent.isInGuardedEventHandler) - throw e + if (LorenzEvent.isInGuardedEventHandler) throw e } } @@ -125,7 +123,7 @@ class ConfigManager { var missingConfigLink = false for (field in obj.javaClass.fields) { field.isAccessible = true - if (field.type != Position::class.java) { + if (field.type != Position::class.java && field.type != PositionList::class.java) { findPositionLinks(field.get(obj), slog) continue } @@ -141,8 +139,13 @@ class ConfigManager { } continue } - val position = field.get(obj) as Position - position.setLink(configLink) + if (field.type == Position::class.java) { + val position = field.get(obj) as Position + position.setLink(configLink) + } else if (field.type == PositionList::class.java) { + val list = field.get(obj) as PositionList + list.setLink(configLink) + } } if (missingConfigLink) { println("") @@ -245,7 +248,7 @@ class ConfigManager { unit.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING, - StandardCopyOption.ATOMIC_MOVE + StandardCopyOption.ATOMIC_MOVE, ) } catch (e: AccessDeniedException) { if (loop == 5) { |