From 544fdb38a545ff346a8d12349067c805caac3862 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Mon, 6 Feb 2023 15:35:49 +0900 Subject: - better unloading Signed-off-by: syeyoung --- .../main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java | 1 + .../dungeonsguide/mod/events/listener/PacketInjector.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java index 7a7ba7fb..b0d67ab0 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -304,6 +304,7 @@ public class DungeonsGuide implements DGInterface { StompManager.getInstance().cleanup(); // have FUN! + for (Object registeredListener : registeredListeners) { MinecraftForge.EVENT_BUS.unregister(registeredListener); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java index 54ba4f8a..676682ff 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java @@ -93,16 +93,16 @@ public class PacketInjector extends ChannelDuplexHandler { super.write(ctx, msg, promise); } - private ChannelPipeline thePipeline; + @SubscribeEvent public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { - (thePipeline =event.manager.channel().pipeline()).addBefore("packet_handler", "dg_packet_handler", this); + event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); } public void cleanup() { try { - if (thePipeline != null) - thePipeline.remove("dg_packet_handler"); + if (Minecraft.getMinecraft().getNetHandler() != null) + Minecraft.getMinecraft().getNetHandler().getNetworkManager().channel().pipeline().remove("dg_packet_handler"); } catch (Exception e) { } -- cgit