From d09480c3d272f270fb1b45c51bc3540b5416c09a Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 8 Sep 2024 07:03:51 +1000 Subject: Backend: Use on DelayedRun to add scheduled tasks (#2462) --- .../java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/test') diff --git a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt index a42a10faf..6e497efca 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt @@ -2,12 +2,12 @@ package at.hannibal2.skyhanni.test.hotswap import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.ReflectionUtils.removeFinal import moe.nea.hotswapagentforge.forge.ClassDefinitionEvent import moe.nea.hotswapagentforge.forge.HotswapEvent import moe.nea.hotswapagentforge.forge.HotswapFinishedEvent -import net.minecraft.client.Minecraft import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -22,7 +22,7 @@ class HotswapSupportImpl : HotswapSupportHandle { fun onHotswapClass(event: ClassDefinitionEvent.Redefinition) { val instance = SkyHanniMod.modules.find { it.javaClass.name == event.fullyQualifiedName } ?: return val primaryConstructor = runCatching { instance.javaClass.getDeclaredConstructor() }.getOrNull() - Minecraft.getMinecraft().addScheduledTask { + DelayedRun.onThread.execute { ChatUtils.chat("Refreshing event subscriptions for module $instance!") MinecraftForge.EVENT_BUS.unregister(instance) if (primaryConstructor == null) { -- cgit