diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-06-01 20:47:08 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-01 12:47:08 +0200 |
commit | a20da5a79b5b05839862c8e8fd165b18368729c1 (patch) | |
tree | ef0b258d90d839867eba8c002f02e1c823b049ef /src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | |
parent | 2698b9d13de081be2e72e63faa213a74cafb6a6b (diff) | |
download | skyhanni-a20da5a79b5b05839862c8e8fd165b18368729c1.tar.gz skyhanni-a20da5a79b5b05839862c8e8fd165b18368729c1.tar.bz2 skyhanni-a20da5a79b5b05839862c8e8fd165b18368729c1.zip |
Backend: Auto load annotation (#1904)
Co-authored-by: Brady <thatgravyboat@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 5d1bb52ad..6fd2154e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.data.ActionBarStatsData import at.hannibal2.skyhanni.data.BitsAPI import at.hannibal2.skyhanni.data.BlockData import at.hannibal2.skyhanni.data.BossbarData -import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.CropAccessoryData import at.hannibal2.skyhanni.data.EntityData import at.hannibal2.skyhanni.data.EntityMovementData @@ -453,6 +452,7 @@ import at.hannibal2.skyhanni.features.stranded.HighlightPlaceableNpcs import at.hannibal2.skyhanni.features.summonings.SummoningMobManager import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.LoadedModules import at.hannibal2.skyhanni.test.HighlightMissingRepoItems import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.ParkourWaypointSaver @@ -512,9 +512,10 @@ class SkyHanniMod { HotswapSupport.load() - // data loadModule(this) - loadModule(ChatManager) + LoadedModules.modules.forEach { loadModule(it) } + + // data loadModule(PlayerChatManager()) loadModule(PlayerNameFormatter()) loadModule(HypixelData()) @@ -1007,9 +1008,13 @@ class SkyHanniMod { } catch (e: Exception) { Exception("Error reading repo data", e).printStackTrace() } + loadedClasses.clear() } + private val loadedClasses = mutableSetOf<Any>() + fun loadModule(obj: Any) { + if (!loadedClasses.add(obj.javaClass.name)) throw IllegalStateException("Module ${obj.javaClass.name} is already loaded") modules.add(obj) MinecraftForge.EVENT_BUS.register(obj) } |