#1841: Fix disabled throttle and improve code.

This commit is contained in:
md_5 2016-04-24 22:18:23 +10:00
parent 2e8ed1cfba
commit 1cd3e42182
3 changed files with 6 additions and 3 deletions

View File

@ -270,7 +270,10 @@ public class BungeeCord extends ProxyServer
pluginManager.enablePlugins();
connectionThrottle = new ConnectionThrottle( config.getThrottle() );
if ( config.getThrottle() > 0 )
{
connectionThrottle = new ConnectionThrottle( config.getThrottle() );
}
startListeners();
saveThread.scheduleAtFixedRate( new TimerTask()

View File

@ -13,7 +13,7 @@ public class ConnectionThrottle
public ConnectionThrottle(int throttleTime)
{
this.throttleTime = throttleTime;
this.throttleTime = throttleTime;
this.throttle = CacheBuilder.newBuilder()
.concurrencyLevel( Runtime.getRuntime().availableProcessors() )
.initialCapacity( 100 )

View File

@ -296,7 +296,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
thisState = State.USERNAME;
ch.setProtocol( Protocol.LOGIN );
if ( bungee.getConnectionThrottle().throttle( ( (InetSocketAddress) ch.getHandle().remoteAddress() ).getAddress() ) )
if ( bungee.getConnectionThrottle() != null && bungee.getConnectionThrottle().throttle( getAddress().getAddress() ) )
{
disconnect( bungee.getTranslation( "join_throttle_kick", TimeUnit.MILLISECONDS.toSeconds( bungee.getConfig().getThrottle() ) ) );
}