diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 92d3d5c71..941485fce 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -1,6 +1,5 @@ package net.md_5.bungee.connection; -import lombok.RequiredArgsConstructor; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.EntityMap; import net.md_5.bungee.UserConnection; @@ -17,16 +16,17 @@ import net.md_5.bungee.protocol.packet.Packet3Chat; import net.md_5.bungee.protocol.packet.PacketCCSettings; import net.md_5.bungee.protocol.packet.PacketFAPluginMessage; -@RequiredArgsConstructor public class UpstreamBridge extends PacketHandler { private final ProxyServer bungee; private final UserConnection con; - @Override - public void added() + public UpstreamBridge(ProxyServer bungee, UserConnection con) { + this.bungee = bungee; + this.con = con; + BungeeCord.getInstance().addConnection( con ); con.getTabList().onConnect(); con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels() ); diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java index 25892f611..c3ed29a8c 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -27,29 +27,34 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { Preconditions.checkArgument( handler != null, "handler" ); this.handler = handler; - this.handler.added(); } @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - channel = new ChannelWrapper( ctx ); - handler.connected( channel ); - - if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) + if ( handler != null ) { - ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler ); + channel = new ChannelWrapper( ctx ); + handler.connected( channel ); + + if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) + { + ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler ); + } } } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { - handler.disconnected( channel ); - - if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) + if ( handler != null ) { - ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler ); + handler.disconnected( channel ); + + if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) ) + { + ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler ); + } } } @@ -58,7 +63,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter { for ( Object msg : msgs ) { - if ( ctx.channel().isActive() ) + if ( handler != null && ctx.channel().isActive() ) { if ( msg instanceof PacketWrapper ) { @@ -98,12 +103,15 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause ); } - try + if ( handler != null ) { - handler.exception( cause ); - } catch ( Exception ex ) - { - ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - exception processing exception", ex ); + try + { + handler.exception( cause ); + } catch ( Exception ex ) + { + ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - exception processing exception", ex ); + } } ctx.close(); diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java b/proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java index 2045b86c3..1440f18c9 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java @@ -14,10 +14,6 @@ public abstract class PacketHandler extends net.md_5.bungee.protocol.packet.Abst { } - public void added() - { - } - public void connected(ChannelWrapper channel) throws Exception { }