aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-06-01 20:47:08 +1000
committerGitHub <noreply@github.com>2024-06-01 12:47:08 +0200
commita20da5a79b5b05839862c8e8fd165b18368729c1 (patch)
treeef0b258d90d839867eba8c002f02e1c823b049ef /src
parent2698b9d13de081be2e72e63faa213a74cafb6a6b (diff)
downloadskyhanni-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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt2
2 files changed, 10 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)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
index 112c29f17..ef032f6fc 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.features.chat.ChatFilterGui
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.IdentityCharacteristics
import at.hannibal2.skyhanni.utils.LorenzLogger
@@ -26,6 +27,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.relauncher.ReflectionHelper
import java.lang.invoke.MethodHandles
+@SkyHanniModule
object ChatManager {
private val loggerAll = LorenzLogger("chat/all")