Add global slot limit. Fixes feature request #40

This commit is contained in:
md_5 2013-03-14 20:14:01 +11:00
parent 9bf6a58ba2
commit ec1de0f636
2 changed files with 6 additions and 2 deletions

View File

@ -48,7 +48,7 @@ public class Configuration
* Should we check minecraft.net auth.
*/
private boolean onlineMode = true;
private int sleepTime = 1;
private int playerLimit = -1;
public void load()
{
@ -58,7 +58,7 @@ public class Configuration
timeout = adapter.getInt( "timeout", timeout );
uuid = adapter.getString( "stats", uuid );
onlineMode = adapter.getBoolean( "online_mode", onlineMode );
sleepTime = adapter.getInt( "sleep_time", sleepTime );
playerLimit = adapter.getInt( "player_limit", playerLimit );
DefaultTabList tab = DefaultTabList.valueOf( adapter.getString( "tab_list", "GLOBAL_PING" ) );
if ( tab == null )

View File

@ -117,6 +117,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
Preconditions.checkArgument( handshake.username.length() <= 16, "Cannot have username longer than 16 characters" );
int limit = BungeeCord.getInstance().config.getPlayerLimit();
Preconditions.checkState( limit <= 0 || bungee.getPlayers().size() < limit, "Server is full!" );
this.handshake = handshake;
ch.write( forgeMods );
ch.write( request = EncryptionUtil.encryptRequest() );