Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.

Commit ff86e68

Browse files
only reorder if event is called
1 parent 912a5b0 commit ff86e68

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/java/de/florianmichael/vialoadingbase/netty/VLBPipeline.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package de.florianmichael.vialoadingbase.netty;
1919

2020
import com.viaversion.viaversion.api.connection.UserConnection;
21+
import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent;
2122
import de.florianmichael.vialoadingbase.netty.handler.VLBViaDecodeHandler;
2223
import de.florianmichael.vialoadingbase.netty.handler.VLBViaEncodeHandler;
2324
import io.netty.channel.ChannelHandler;
@@ -46,18 +47,20 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
4647
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
4748
super.userEventTriggered(ctx, evt);
4849

49-
final int decoderIndex = ctx.pipeline().names().indexOf(getDecompressionHandlerName());
50-
if (decoderIndex == -1) return;
50+
if (evt instanceof CompressionReorderEvent) {
51+
final int decoderIndex = ctx.pipeline().names().indexOf(getDecompressionHandlerName());
52+
if (decoderIndex == -1) return;
5153

52-
if (decoderIndex > ctx.pipeline().names().indexOf(VIA_DECODER_HANDLER_NAME)) {
53-
final ChannelHandler decoder = ctx.pipeline().get(VIA_DECODER_HANDLER_NAME);
54-
final ChannelHandler encoder = ctx.pipeline().get(VIA_ENCODER_HANDLER_NAME);
54+
if (decoderIndex > ctx.pipeline().names().indexOf(VIA_DECODER_HANDLER_NAME)) {
55+
final ChannelHandler decoder = ctx.pipeline().get(VIA_DECODER_HANDLER_NAME);
56+
final ChannelHandler encoder = ctx.pipeline().get(VIA_ENCODER_HANDLER_NAME);
5557

56-
ctx.pipeline().remove(decoder);
57-
ctx.pipeline().remove(encoder);
58+
ctx.pipeline().remove(decoder);
59+
ctx.pipeline().remove(encoder);
5860

59-
ctx.pipeline().addAfter(getDecompressionHandlerName(), VIA_DECODER_HANDLER_NAME, decoder);
60-
ctx.pipeline().addAfter(getCompressionHandlerName(), VIA_ENCODER_HANDLER_NAME, encoder);
61+
ctx.pipeline().addAfter(getDecompressionHandlerName(), VIA_DECODER_HANDLER_NAME, decoder);
62+
ctx.pipeline().addAfter(getCompressionHandlerName(), VIA_ENCODER_HANDLER_NAME, encoder);
63+
}
6164
}
6265
}
6366

0 commit comments

Comments
 (0)