spigot/CraftBukkit-Patches/0033-Configurable-Ping-Sample-Size.patch

44 lines
2 KiB
Diff
Raw Normal View History

2024-10-23 02:15:00 +11:00
From 0617e3c211b9af95560a54c0e93e779e0a6445b7 Mon Sep 17 00:00:00 2001
2014-04-12 14:18:37 +10:00
From: md_5 <git@md-5.net>
Date: Sun, 26 Jan 2014 21:48:34 +1100
Subject: [PATCH] Configurable Ping Sample Size
2021-03-16 09:00:00 +11:00
diff --git a/src/main/java/net/minecraft/server/network/PacketStatusListener.java b/src/main/java/net/minecraft/server/network/PacketStatusListener.java
2024-06-22 08:09:33 +10:00
index 51ad3590a8..09af460031 100644
2021-03-16 09:00:00 +11:00
--- a/src/main/java/net/minecraft/server/network/PacketStatusListener.java
+++ b/src/main/java/net/minecraft/server/network/PacketStatusListener.java
2024-06-14 01:05:00 +10:00
@@ -134,6 +134,13 @@ public class PacketStatusListener implements PacketStatusInListener {
2023-03-15 03:30:00 +11:00
}
2021-11-24 07:30:51 +11:00
}
2014-04-12 14:18:37 +10:00
2023-03-15 03:30:00 +11:00
+ // 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
2024-06-22 08:09:33 +10:00
ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), event.getNumPlayers(), (server.hidesOnlinePlayers()) ? Collections.emptyList() : profiles);
2023-03-15 03:30:00 +11:00
ServerPing ping = new ServerPing(
2014-04-12 14:18:37 +10:00
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2024-06-14 01:05:00 +10:00
index cf09bd207b..175b389e55 100644
2014-04-12 14:18:37 +10:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2019-07-30 20:52:01 +10:00
@@ -271,4 +271,11 @@ public class SpigotConfig
2014-04-12 14:18:37 +10:00
{
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 );
+ }
}
--
2024-10-23 02:15:00 +11:00
2.47.0
2014-04-12 14:18:37 +10:00