[#1567] Let BungeeCord dictate the network compression threshold.

This commit is contained in:
md_5 2015-09-13 09:28:21 +10:00
parent 06ad0f9310
commit 4e94c278da
2 changed files with 9 additions and 5 deletions

View File

@ -52,6 +52,7 @@ public class Configuration implements ProxyConfig
private int throttle = 4000;
private boolean ipForward;
private Favicon favicon;
private int compressionThreshold = 256;
public void load()
{
@ -77,6 +78,7 @@ public class Configuration implements ProxyConfig
playerLimit = adapter.getInt( "player_limit", playerLimit );
throttle = adapter.getInt( "connection_throttle", throttle );
ipForward = adapter.getBoolean( "ip_forward", ipForward );
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );

View File

@ -433,7 +433,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
// TODO See #1218
oldID.disconnect( bungee.getTranslation( "already_connected" ) );
}
} else {
} else
{
// In offline mode the existing user stays and we kick the new one
ProxiedPlayer oldName = bungee.getPlayer( getName() );
if ( oldName != null )
@ -473,6 +474,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
if ( ch.getHandle().isActive() )
{
UserConnection userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
userCon.init();
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_7_6 )
{
unsafe.sendPacket( new LoginSuccess( getUniqueId().toString(), getName() ) ); // With dashes in between
@ -482,9 +487,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
ch.setProtocol( Protocol.GAME );
UserConnection userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
userCon.init();
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
ServerInfo server;
@ -535,7 +537,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Override
public void run()
{
if (thisState != State.STATUS && thisState != State.PING)
if ( thisState != State.STATUS && thisState != State.PING )
{
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
}