Cut CPU load to sane amounts in the same way that Minecraft does.

This commit is contained in:
md_5 2013-02-16 12:41:26 +11:00
parent feb64312ca
commit 0b10f83916
2 changed files with 16 additions and 0 deletions

View File

@ -331,6 +331,13 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
{ {
server.stream.write( packet ); server.stream.write( packet );
} }
try
{
Thread.sleep( BungeeCord.getInstance().config.getSleepTime() );
} catch ( InterruptedException ex )
{
}
} catch ( IOException ex ) } catch ( IOException ex )
{ {
destroySelf( "Reached end of stream" ); destroySelf( "Reached end of stream" );
@ -526,6 +533,13 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
connect( nextServer, true ); connect( nextServer, true );
break outer; break outer;
} }
try
{
Thread.sleep( BungeeCord.getInstance().config.getSleepTime() );
} catch ( InterruptedException ex )
{
}
} }
} catch ( Exception ex ) } catch ( Exception ex )
{ {

View File

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