3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Only inject channels when server protocol is known #631

Dieser Commit ist enthalten in:
Myles 2017-02-13 17:22:52 +00:00
Ursprung 280da6b8e9
Commit 99e4ab22e3
2 geänderte Dateien mit 37 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -7,6 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; 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.ClassGenerator;
import us.myles.ViaVersion.bukkit.classgenerator.HandlerConstructor; import us.myles.ViaVersion.bukkit.classgenerator.HandlerConstructor;
@ -33,6 +34,8 @@ public class BukkitChannelInitializer extends ChannelInitializer<SocketChannel>
@Override @Override
protected void initChannel(SocketChannel socketChannel) throws Exception { protected void initChannel(SocketChannel socketChannel) throws Exception {
// Ensure ViaVersion is loaded
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
UserConnection info = new UserConnection(socketChannel); UserConnection info = new UserConnection(socketChannel);
// init protocol // init protocol
new ProtocolPipeline(info); new ProtocolPipeline(info);
@ -48,5 +51,8 @@ public class BukkitChannelInitializer extends ChannelInitializer<SocketChannel>
socketChannel.pipeline().replace("encoder", "encoder", encoder); socketChannel.pipeline().replace("encoder", "encoder", encoder);
socketChannel.pipeline().replace("decoder", "decoder", decoder); socketChannel.pipeline().replace("decoder", "decoder", decoder);
socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler);
} else {
this.method.invoke(this.original, socketChannel);
}
} }
} }

Datei anzeigen

@ -7,6 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -31,6 +32,8 @@ public class SpongeChannelInitializer extends ChannelInitializer<SocketChannel>
@Override @Override
protected void initChannel(SocketChannel socketChannel) throws Exception { protected void initChannel(SocketChannel socketChannel) throws Exception {
// Ensure ViaVersion is loaded
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
UserConnection info = new UserConnection(socketChannel); UserConnection info = new UserConnection(socketChannel);
// init protocol // init protocol
new ProtocolPipeline(info); new ProtocolPipeline(info);
@ -44,5 +47,8 @@ public class SpongeChannelInitializer extends ChannelInitializer<SocketChannel>
socketChannel.pipeline().replace("encoder", "encoder", encoder); socketChannel.pipeline().replace("encoder", "encoder", encoder);
socketChannel.pipeline().replace("decoder", "decoder", decoder); socketChannel.pipeline().replace("decoder", "decoder", decoder);
socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); socketChannel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler);
} else {
this.method.invoke(this.original, socketChannel);
}
} }
} }