diff options
4 files changed, 28 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 0d4afe7de..cf310e364 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -47,6 +47,9 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.ArrayList; +import java.util.List; + @Mod(modid = SkyHanniMod.MODID, version = SkyHanniMod.VERSION) public class SkyHanniMod { @@ -59,6 +62,8 @@ public class SkyHanniMod { public static ConfigManager configManager; private static Logger logger; + public static List<Object> listenerClasses = new ArrayList<>(); + @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = LogManager.getLogger("SkyHanni"); @@ -142,6 +147,7 @@ public class SkyHanniMod { } private void registerEvent(Object object) { + listenerClasses.add(object); String simpleName = object.getClass().getSimpleName(); consoleLog("SkyHanni registering '" + simpleName + "'"); long start = System.currentTimeMillis(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java index 3dd4a5262..460de1b7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java @@ -108,5 +108,15 @@ public class Commands { } ) ); + ClientCommandHandler.instance.registerCommand( + new SimpleCommand( + "shreloadlisteners", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + LorenzTest.Companion.reloadListeners(); + } + } + ) + ); } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index cc18898ee..506894a9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -5,7 +5,7 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event abstract class LorenzEvent: Event() { - val eventName by lazy { + private val eventName by lazy { this::class.simpleName } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index 9bd5922b0..47e6c1491 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.PlayParticleEvent import at.hannibal2.skyhanni.events.PlaySoundEvent @@ -14,6 +15,7 @@ import net.minecraft.event.HoverEvent import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.ChatComponentText import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.entity.living.EnderTeleportEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -87,6 +89,15 @@ class LorenzTest { text = "" + highestStep } } + + fun reloadListeners() { + val listenerClasses = SkyHanniMod.listenerClasses + for (any in listenerClasses) { + MinecraftForge.EVENT_BUS.unregister(any) + MinecraftForge.EVENT_BUS.register(any) + } + LorenzUtils.chat("§e[SkyHanni] reloaded ${listenerClasses.size} listener classes.") + } } @SubscribeEvent |