diff options
Diffstat (limited to 'CraftBukkit-Patches/0089-Configurable-Ping-Sample-Size.patch')
-rw-r--r-- | CraftBukkit-Patches/0089-Configurable-Ping-Sample-Size.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/CraftBukkit-Patches/0089-Configurable-Ping-Sample-Size.patch b/CraftBukkit-Patches/0089-Configurable-Ping-Sample-Size.patch new file mode 100644 index 0000000000..298043bb4c --- /dev/null +++ b/CraftBukkit-Patches/0089-Configurable-Ping-Sample-Size.patch @@ -0,0 +1,43 @@ +From 67e1c4618a1dabe19a00d6d33a5a5719dff6c8b1 Mon Sep 17 00:00:00 2001 +From: md_5 <[email protected]> +Date: Sun, 26 Jan 2014 21:48:34 +1100 +Subject: [PATCH] Configurable Ping Sample Size + + +diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java +index cd06305..6423aec 100644 +--- a/src/main/java/net/minecraft/server/PacketStatusListener.java ++++ b/src/main/java/net/minecraft/server/PacketStatusListener.java +@@ -110,6 +110,13 @@ public class PacketStatusListener implements PacketStatusInListener { + } + + ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); ++ // Spigot Start ++ if ( !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 + playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); + + ServerPing ping = new ServerPing(); +diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java +index 3f45433..2c2b978 100644 +--- a/src/main/java/org/spigotmc/SpigotConfig.java ++++ b/src/main/java/org/spigotmc/SpigotConfig.java +@@ -260,4 +260,11 @@ public class SpigotConfig + { + commands.put( "tps", new TicksPerSecondCommand( "tps" ) ); + } ++ ++ public static int playerSample; ++ private static void playerSample() ++ { ++ playerSample = getInt( "settings.sample-count", 12 ); ++ System.out.println( "Server Ping Player Sample Count: " + playerSample ); ++ } + } +-- +1.9.1 + |