From 140830efe0b1050c53925791d4e47fd60a470482 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 3 May 2013 14:16:48 +1000 Subject: [PATCH] Close #300 - cleaner disconnects when server is full --- .../java/net/md_5/bungee/connection/InitialHandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index b44e3f05..08b311a6 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -109,7 +109,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection } int limit = BungeeCord.getInstance().config.getPlayerLimit(); - Preconditions.checkState( limit <= 0 || bungee.getPlayers().size() < limit, "Server is full!" ); + if ( limit > 0 && bungee.getPlayers().size() > limit ) + { + disconnect( "Server is full!" ); + return; + } this.handshake = handshake; ch.write( request = EncryptionUtil.encryptRequest() ); @@ -210,7 +214,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection { Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" ); - UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch,getName(), this ); + UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, getName(), this ); userCon.init(); bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );