Configurable Ping Sample Size

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2014-01-26 21:48:34 +11:00
parent cd82f21617
commit 23c02d0942
2 changed files with 15 additions and 1 deletions

View File

@ -20,7 +20,7 @@
public class ServerStatusPacketListenerImpl implements ServerStatusPacketListener {
@@ -36,7 +49,101 @@
@@ -36,7 +49,108 @@
this.connection.disconnect(ServerStatusPacketListenerImpl.DISCONNECT_REASON);
} else {
this.hasRequestedStatus = true;
@ -108,6 +108,13 @@
+ }
+ }
+
+ // Spigot Start
+ if ( !server.hidesOnlinePlayers() && !profiles.isEmpty() )
+ {
+ java.util.Collections.shuffle( profiles ); // This sucks, its inefficient but we have no simple way of doing it differently
+ profiles = profiles.subList( 0, Math.min( profiles.size(), org.spigotmc.SpigotConfig.playerSample ) ); // Cap the sample to n (or less) displayed players, ie: Vanilla behaviour
+ }
+ // Spigot End
+ ServerStatus.Players playerSample = new ServerStatus.Players(event.getMaxPlayers(), event.getNumPlayers(), (server.hidesOnlinePlayers()) ? Collections.emptyList() : profiles);
+
+ ServerStatus ping = new ServerStatus(

View File

@ -271,4 +271,11 @@ public class SpigotConfig
{
SpigotConfig.commands.put( "tps", new TicksPerSecondCommand( "tps" ) );
}
public static int playerSample;
private static void playerSample()
{
SpigotConfig.playerSample = SpigotConfig.getInt( "settings.sample-count", 12 );
System.out.println( "Server Ping Player Sample Count: " + SpigotConfig.playerSample );
}
}