From 5ba0fb7ab33e71d28e62910568de0865bbfe3c8c Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 17 Nov 2022 22:53:32 +0900 Subject: - Unload packet handler Signed-off-by: syeyoung --- .../dungeonsguide/mod/events/listener/PacketListener.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mod/src/main/java/kr') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java index fe907a5b..acfffb7c 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java @@ -18,10 +18,7 @@ package kr.syeyoung.dungeonsguide.mod.events.listener; -import io.netty.channel.ChannelDuplexHandler; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; +import io.netty.channel.*; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.cosmetics.CustomPacketPlayerListItem; @@ -184,8 +181,13 @@ public class PacketListener extends ChannelDuplexHandler { super.write(ctx, msg, promise); } + private ChannelPipeline thePipeline; @SubscribeEvent public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { - event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); + (thePipeline =event.manager.channel().pipeline()).addBefore("packet_handler", "dg_packet_handler", this); + } + + public void cleanup() { + thePipeline.remove("dg_packet_handler"); } } -- cgit