diff --git a/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java b/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java index a0ae31ab..30791147 100644 --- a/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java +++ b/core/src/main/java/com/rexcantor64/triton/BungeeMLP.java @@ -20,7 +20,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; @@ -60,7 +59,7 @@ public void onEnable() { for (ProxiedPlayer p : getBungeeCord().getPlayers()) { BungeeLanguagePlayer lp = (BungeeLanguagePlayer) getPlayerManager().get(p.getUniqueId()); - injectPipeline(lp, p); + injectPipeline(lp, p, p.getPendingConnection().getVersion()); } val commandHandler = new BungeeCommandHandler(); @@ -115,19 +114,12 @@ 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 = NMSUtils.getDeclaredField(p, "ch"); Method method = ch.getClass().getDeclaredMethod("getHandle"); Channel channel = (Channel) method.invoke(ch, new Object[0]); - 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() diff --git a/core/src/main/java/com/rexcantor64/triton/listeners/BungeeListener.java b/core/src/main/java/com/rexcantor64/triton/listeners/BungeeListener.java index 2eaa0a2c..7eb68869 100644 --- a/core/src/main/java/com/rexcantor64/triton/listeners/BungeeListener.java +++ b/core/src/main/java/com/rexcantor64/triton/listeners/BungeeListener.java @@ -46,7 +46,7 @@ public void onLogin(LoginEvent event) { Triton.asBungee().getBungeeCord().getScheduler().runAsync(plugin, () -> { val lp = new BungeeLanguagePlayer(event.getConnection().getUniqueId(), event.getConnection()); Triton.get().getPlayerManager().registerPlayer(lp); - BungeeMLP.asBungee().injectPipeline(lp, event.getConnection()); + BungeeMLP.asBungee().injectPipeline(lp, event.getConnection(), event.getConnection().getVersion()); event.completeIntent(plugin); }); }