From edd1f10c784728913983e26ac40b49c485ad3a8e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:51:29 +0100 Subject: Add test command /shstoplisteners --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../java/at/hannibal2/skyhanni/config/commands/Commands.kt | 1 + src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index ef768b6ef..f99a0ee2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -186,7 +186,7 @@ public class SkyHanniMod { repo.loadRepoInformation(); } - private void loadModule(Object object) { + public void loadModule(Object object) { modules.add(object); MinecraftForge.EVENT_BUS.register(object); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 9bda0fda1..c8e8d8889 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -37,6 +37,7 @@ object Commands { registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) } registerCommand("togglepacketlog") { LorenzTest.togglePacketLog() } registerCommand("shreloadlisteners") { LorenzTest.reloadListeners() } + registerCommand("shstoplisteners") { LorenzTest.stopListeners() } registerCommand("shresetburrowwarps") { BurrowWarpHelper.resetDisabledWarps() } registerCommand("shtrackcollection") { CollectionCounter.command(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index f7ab6a90b..f72430139 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -103,6 +103,17 @@ class LorenzTest { } LorenzUtils.chat("§e[SkyHanni] reloaded ${modules.size} listener classes.") } + + fun stopListeners() { + val modules = SkyHanniMod.modules + for (original in modules.toMutableList()) { + val javaClass = original.javaClass + val simpleName = javaClass.simpleName + MinecraftForge.EVENT_BUS.unregister(original) + println("Unregistered listener $simpleName") + } + LorenzUtils.chat("§e[SkyHanni] stopped ${modules.size} listener classes.") + } } @SubscribeEvent -- cgit