diff --git a/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/BungeeTriton.java b/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/BungeeTriton.java index da929d0d..b72a1d73 100644 --- a/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/BungeeTriton.java +++ b/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/BungeeTriton.java @@ -22,7 +22,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.scheduler.ScheduledTask; import net.md_5.bungee.netty.PipelineUtils; -import net.md_5.bungee.protocol.MinecraftEncoder; import org.bstats.bungeecord.Metrics; import org.bstats.charts.SingleLineChart; @@ -67,7 +66,7 @@ public void onEnable() { for (ProxiedPlayer p : getBungeeCord().getPlayers()) { BungeeLanguagePlayer lp = getPlayerManager().get(p.getUniqueId()); - injectPipeline(lp, p); + injectPipeline(lp, p, p.getPendingConnection().getVersion()); } val commandHandler = new BungeeCommandHandler(); @@ -122,20 +121,19 @@ public String getVersion() { return getLoader().getDescription().getVersion(); } - public void injectPipeline(BungeeLanguagePlayer lp, Connection p) { + public void injectPipeline(BungeeLanguagePlayer lp, Connection p, int protocolVersion) { Triton.get().getLogger().logTrace("Injecting pipeline for player %1", lp); try { Object ch = ReflectionUtils.getDeclaredField(p, "ch"); Method method = ch.getClass().getDeclaredMethod("getHandle"); Channel channel = (Channel) method.invoke(ch, new Object[0]); - int protocolVersion = (int) ReflectionUtils.getDeclaredField(channel.pipeline().get(MinecraftEncoder.class), "protocolVersion"); + 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()); } } diff --git a/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/listeners/BungeeListener.java b/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/listeners/BungeeListener.java index bf12ba13..e12c8c21 100644 --- a/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/listeners/BungeeListener.java +++ b/triton-bungeecord/src/main/java/com/rexcantor64/triton/bungeecord/listeners/BungeeListener.java @@ -48,7 +48,7 @@ public void onLogin(LoginEvent event) { BungeeTriton.asBungee().getBungeeCord().getScheduler().runAsync(plugin, () -> { val lp = new BungeeLanguagePlayer(event.getConnection().getUniqueId(), event.getConnection()); BungeeTriton.asBungee().getPlayerManager().registerPlayer(lp); - BungeeTriton.asBungee().injectPipeline(lp, event.getConnection()); + BungeeTriton.asBungee().injectPipeline(lp, event.getConnection(), event.getConnection().getVersion()); event.completeIntent(plugin); }); }