diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index b4cc85b23be..b0fbbbf0cde 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -46,6 +46,10 @@ public void sendPacket(DefinedPacket packet) public void sendPacketQueued(DefinedPacket packet) { Protocol encodeProtocol = ch.getEncodeProtocol(); + if ( encodeProtocol == null ) + { + return; + } if ( !encodeProtocol.TO_SERVER.hasPacket( packet.getClass(), ch.getEncodeVersion() ) ) { packetQueue.add( packet ); diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 2359e864720..b6e1241e617 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -187,6 +187,10 @@ public void sendPacket(PacketWrapper packet) public void sendPacketQueued(DefinedPacket packet) { Protocol encodeProtocol = ch.getEncodeProtocol(); + if ( encodeProtocol == null ) + { + return; + } if ( !encodeProtocol.TO_CLIENT.hasPacket( packet.getClass(), getPendingConnection().getVersion() ) ) { packetQueue.add( packet ); diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java index 682bb807343..a234df01bf2 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java @@ -42,23 +42,32 @@ public ChannelWrapper(ChannelHandlerContext ctx) public Protocol getDecodeProtocol() { - return ch.pipeline().get( MinecraftDecoder.class ).getProtocol(); + MinecraftDecoder minecraftDecoder = getMinecraftDecoder(); + if ( minecraftDecoder == null ) + { + return null; + } + return minecraftDecoder.getProtocol(); } public void setDecodeProtocol(Protocol protocol) { - ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol ); + getMinecraftDecoder().setProtocol( protocol ); } public Protocol getEncodeProtocol() { - return ch.pipeline().get( MinecraftEncoder.class ).getProtocol(); - + MinecraftEncoder minecraftEncoder = getMinecraftEncoder(); + if ( minecraftEncoder == null ) + { + return null; + } + return minecraftEncoder.getProtocol(); } public void setEncodeProtocol(Protocol protocol) { - ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol ); + getMinecraftEncoder().setProtocol( protocol ); } public void setProtocol(Protocol protocol) @@ -69,13 +78,23 @@ public void setProtocol(Protocol protocol) public void setVersion(int protocol) { - ch.pipeline().get( MinecraftDecoder.class ).setProtocolVersion( protocol ); - ch.pipeline().get( MinecraftEncoder.class ).setProtocolVersion( protocol ); + getMinecraftDecoder().setProtocolVersion( protocol ); + getMinecraftEncoder().setProtocolVersion( protocol ); + } + + public MinecraftDecoder getMinecraftDecoder() + { + return ch.pipeline().get( MinecraftDecoder.class ); + } + + public MinecraftEncoder getMinecraftEncoder() + { + return ch.pipeline().get( MinecraftEncoder.class ); } public int getEncodeVersion() { - return ch.pipeline().get( MinecraftEncoder.class ).getProtocolVersion(); + return getMinecraftEncoder().getProtocolVersion(); } public void write(Object packet)