diff options
author | Linnea Gräf <nea@nea.moe> | 2024-04-08 18:45:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 18:45:11 +0200 |
commit | 878f8ee718c43d66e068f40e1c2ef7d30abb7ac4 (patch) | |
tree | a81a5d1496c2bf4f654e2874c572730fb0b1e9cd /src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt | |
parent | ff6dd291a0f89644508171e6b984295de20466ce (diff) | |
download | skyhanni-878f8ee718c43d66e068f40e1c2ef7d30abb7ac4.tar.gz skyhanni-878f8ee718c43d66e068f40e1c2ef7d30abb7ac4.tar.bz2 skyhanni-878f8ee718c43d66e068f40e1c2ef7d30abb7ac4.zip |
Add hud element config links. (#1383)
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 | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index 3fbf41541..65c252bae 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -1,15 +1,18 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson import at.hannibal2.skyhanni.data.jsonobjects.other.HypixelApiTrophyFish +import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.utils.FeatureTogglesByDefaultAdapter +import at.hannibal2.skyhanni.utils.IdentityCharacteristics import at.hannibal2.skyhanni.utils.KotlinTypeAdapterFactory import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzRarity @@ -29,6 +32,7 @@ import com.google.gson.TypeAdapterFactory import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink import io.github.notenoughupdates.moulconfig.observer.PropertyTypeAdapterFactory import io.github.notenoughupdates.moulconfig.processor.BuiltinMoulConfigGuis import io.github.notenoughupdates.moulconfig.processor.ConfigProcessorDriver @@ -214,6 +218,31 @@ class ConfigManager { BuiltinMoulConfigGuis.addProcessors(processor) UpdateManager.injectConfigProcessor(processor) ConfigProcessorDriver(processor).processConfig(features) + + try { + findPositionLinks(features, mutableSetOf()) + } catch (e: Exception) { + if (LorenzEvent.isInGuardedEventHandler) + throw e + } + } + + private fun findPositionLinks(obj: Any?, slog: MutableSet<IdentityCharacteristics<Any>>) { + if (obj == null) return + if (!obj.javaClass.name.startsWith("at.hannibal2.skyhanni.")) return + val ic = IdentityCharacteristics(obj) + if (ic in slog) return + slog.add(ic) + for (field in obj.javaClass.fields) { + field.isAccessible = true + if (field.type != Position::class.java) { + findPositionLinks(field.get(obj), slog) + continue + } + val configLink = field.getAnnotation(ConfigLink::class.java) ?: continue + val position = field.get(obj) as Position + position.setLink(configLink) + } } private fun firstLoadFile(file: File?, fileType: ConfigFileType, defaultValue: Any): Any { |