diff --git a/LICENSE b/LICENSE index c2288aac4..4ddc63b9a 100644 --- a/LICENSE +++ b/LICENSE @@ -3,7 +3,7 @@ License: MIT License -Copyright (c) 2016 +Copyright (c) 2017 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,4 +21,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. 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(); diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeChannelInitializer.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeChannelInitializer.java index 88248d769..319f9e26e 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeChannelInitializer.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeChannelInitializer.java @@ -7,6 +7,7 @@ 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 java.lang.reflect.Method; @@ -31,18 +32,23 @@ public class SpongeChannelInitializer extends ChannelInitializer @Override protected void initChannel(SocketChannel socketChannel) throws Exception { - UserConnection info = new UserConnection(socketChannel); - // init protocol - new ProtocolPipeline(info); - // Add originals - this.method.invoke(this.original, socketChannel); - // Add our transformers - MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder")); - ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder")); - SpongePacketHandler chunkHandler = new SpongePacketHandler(info); + // 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); + // Add our transformers + MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) socketChannel.pipeline().get("encoder")); + ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) socketChannel.pipeline().get("decoder")); + SpongePacketHandler chunkHandler = new SpongePacketHandler(info); - socketChannel.pipeline().replace("encoder", "encoder", encoder); - socketChannel.pipeline().replace("decoder", "decoder", decoder); - socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); + 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); + } } }