From 3fdbf5b0627d4ad3b756bf6d05f6f652563147aa Mon Sep 17 00:00:00 2001 From: Myles Date: Fri, 17 Feb 2017 14:15:27 +0000 Subject: [PATCH] Revert previous Server protocol check, add a call to ProtocolRegistry to force class load. --- .../handlers/BukkitChannelInitializer.java | 32 ++++++++----------- .../java/us/myles/ViaVersion/ViaManager.java | 2 ++ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitChannelInitializer.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitChannelInitializer.java index 268eaf72f..a4529ad3a 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitChannelInitializer.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitChannelInitializer.java @@ -7,7 +7,6 @@ import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.MessageToByteEncoder; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.protocol.ProtocolPipeline; -import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator; import us.myles.ViaVersion.bukkit.classgenerator.HandlerConstructor; @@ -34,25 +33,20 @@ public class BukkitChannelInitializer extends ChannelInitializer @Override protected void initChannel(SocketChannel socketChannel) throws Exception { - // Ensure ViaVersion is loaded - if (ProtocolRegistry.SERVER_PROTOCOL != -1) { - UserConnection info = new UserConnection(socketChannel); - // init protocol - new ProtocolPipeline(info); - // Add originals - this.method.invoke(this.original, socketChannel); + UserConnection info = new UserConnection(socketChannel); + // init protocol + new ProtocolPipeline(info); + // Add originals + this.method.invoke(this.original, socketChannel); - HandlerConstructor constructor = ClassGenerator.getConstructor(); - // Add our transformers - MessageToByteEncoder encoder = constructor.newEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder")); - ByteToMessageDecoder decoder = constructor.newDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder")); - BukkitPacketHandler chunkHandler = new BukkitPacketHandler(info); + HandlerConstructor constructor = ClassGenerator.getConstructor(); + // Add our transformers + MessageToByteEncoder encoder = constructor.newEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder")); + ByteToMessageDecoder decoder = constructor.newDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder")); + BukkitPacketHandler chunkHandler = new BukkitPacketHandler(info); - socketChannel.pipeline().replace("encoder", "encoder", encoder); - socketChannel.pipeline().replace("decoder", "decoder", decoder); - socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); - } else { - this.method.invoke(this.original, socketChannel); - } + socketChannel.pipeline().replace("encoder", "encoder", encoder); + socketChannel.pipeline().replace("decoder", "decoder", decoder); + socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); } } diff --git a/common/src/main/java/us/myles/ViaVersion/ViaManager.java b/common/src/main/java/us/myles/ViaVersion/ViaManager.java index 60a9254aa..8df0bf6aa 100644 --- a/common/src/main/java/us/myles/ViaVersion/ViaManager.java +++ b/common/src/main/java/us/myles/ViaVersion/ViaManager.java @@ -46,6 +46,8 @@ public class ViaManager { // Check for updates if (platform.getConf().isCheckForUpdates()) UpdateUtil.sendUpdateMessage(); + // Force class load + ProtocolRegistry.getSupportedVersions(); // Inject try { injector.inject();