From 83d48c6aeee1656c5a6966839a1951e67fccbc53 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:59:58 +0200 Subject: Feature: Display Tab Widgets (#1276) Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/config/ConfigManager.kt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt') 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).set(value) + @Suppress("UNCHECKED_CAST") (type.property as KMutableProperty0).set(value) (jsonHolder as MutableMap)[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) { -- cgit