diff --git a/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java b/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java index b18247a5..a0ae31ab 100644 --- a/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java +++ b/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java @@ -121,14 +121,20 @@ public void injectPipeline(BungeeLanguagePlayer lp, Connection p) { Object ch = NMSUtils.getDeclaredField(p, "ch"); Method method = ch.getClass().getDeclaredMethod("getHandle"); Channel channel = (Channel) method.invoke(ch, new Object[0]); - int protocolVersion = (int) NMSUtils.getDeclaredField(channel.pipeline().get(MinecraftEncoder.class), "protocolVersion"); + MinecraftEncoder encoder = channel.pipeline().get(MinecraftEncoder.class); + if (encoder == null) { + getLogger().logWarning("[PacketInjector] Player %1's pipeline does not have a MinecraftEncoder. Failed to get protocol version. Ignore this if the player was kicked from the server.", + lp.getUUID()); + return; + } + int protocolVersion = encoder.getProtocolVersion(); + channel.pipeline().addAfter(PipelineUtils.PACKET_DECODER, "triton-custom-decoder", new BungeeDecoder(lp)); channel.pipeline() .addAfter(PipelineUtils.PACKET_ENCODER, "triton-custom-encoder", new BungeeListener(lp, protocolVersion)); channel.pipeline().remove("triton-pre-login-encoder"); } catch (Exception e) { - getLogger().logError("[PacketInjector] Failed to inject client connection for %1", lp.getUUID()); - e.printStackTrace(); + getLogger().logError(e, "[PacketInjector] Failed to inject client connection for %1", lp.getUUID()); } }