Allow configuring of player sample size, and default the sample to 12, the same as Vanilla. This has some performance overhead, as we have to shuffle the list each time, but this is better than the server displaying as offline!
This commit is contained in:
parent
ab3c5a42f7
commit
6eefe4e38e
|
@ -1,4 +1,4 @@
|
|||
From 8c02318a4530387c90f7598946c11aff46598f38 Mon Sep 17 00:00:00 2001
|
||||
From a0578eaf45465a0cb6435b366301f57724913b1e Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 2 Jul 2013 13:07:39 +1000
|
||||
Subject: [PATCH] POM Changes
|
||||
|
@ -142,9 +142,18 @@ index 2f06c8e..bec994f 100644
|
|||
<execution>
|
||||
<phase>package</phase>
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index f3e5200..596bfcf 100644
|
||||
index f3e5200..4a525d2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -145,7 +145,7 @@ import com.google.common.collect.MapMaker;
|
||||
import jline.console.ConsoleReader;
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "CraftBukkit";
|
||||
+ private final String serverName = "Spigot"; // Spigot
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final ServicesManager servicesManager = new SimpleServicesManager();
|
||||
@@ -226,7 +226,7 @@ public final class CraftServer implements Server {
|
||||
loadIcon();
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
From b4b40136836eb29b280e64679db230a85078905a Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
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 7903c43..f9da452 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 6634292..d26b621 100755
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -253,4 +253,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.8.3.2
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
From f39f990d2c3c43cad0ac0571c9802c2b2eed5301 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Sun, 26 Jan 2014 12:13:31 +1100
|
||||
Subject: [PATCH] Fix Ping Player Sample
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 022e032..9c602b4 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -105,6 +105,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
private static final int TPS = 20;
|
||||
private static final int TICK_TIME = 1000000000 / TPS;
|
||||
public final double[] recentTps = new double[ 3 ];
|
||||
+ public EntityPlayer[] pingPlayers = new EntityPlayer[ 0 ];
|
||||
// Spigot end
|
||||
|
||||
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
|
||||
@@ -561,15 +562,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
if (i - this.T >= 5000000000L) {
|
||||
this.T = i;
|
||||
this.p.setPlayerSample(new ServerPingPlayerSample(this.C(), this.B()));
|
||||
- GameProfile[] agameprofile = new GameProfile[Math.min(this.B(), 12)];
|
||||
+ EntityPlayer[] agameprofile = new EntityPlayer[Math.min(this.B(), 12)]; // Spigot
|
||||
int j = MathHelper.nextInt(this.q, 0, this.B() - agameprofile.length);
|
||||
|
||||
for (int k = 0; k < agameprofile.length; ++k) {
|
||||
- agameprofile[k] = ((EntityPlayer) this.t.players.get(j + k)).getProfile();
|
||||
+ agameprofile[k] = ((EntityPlayer) this.t.players.get(j + k)); // Spigot
|
||||
}
|
||||
|
||||
Collections.shuffle(Arrays.asList(agameprofile));
|
||||
- this.p.b().a(agameprofile);
|
||||
+ // Spigot Start
|
||||
+ GameProfile[] profiles = new GameProfile[ agameprofile.length ];
|
||||
+ for ( int l = 0; l < profiles.length; l++ )
|
||||
+ {
|
||||
+ profiles[l] = agameprofile[l].getProfile();
|
||||
+ }
|
||||
+ this.p.b().a( profiles );
|
||||
+ this.pingPlayers = agameprofile;
|
||||
+ // Spigot End
|
||||
}
|
||||
|
||||
if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java
|
||||
index 7903c43..6480971 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketStatusListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketStatusListener.java
|
||||
@@ -35,7 +35,7 @@ public class PacketStatusListener implements PacketStatusInListener {
|
||||
|
||||
public void a(PacketStatusInStart packetstatusinstart) {
|
||||
// CraftBukkit start - fire ping event
|
||||
- final Object[] players = minecraftServer.getPlayerList().players.toArray();
|
||||
+ final Object[] players = minecraftServer.pingPlayers;
|
||||
class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
|
||||
CraftIconCache icon = minecraftServer.server.getServerIcon();
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PacketStatusListener implements PacketStatusInListener {
|
||||
}
|
||||
}
|
||||
|
||||
- ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
|
||||
+ ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), minecraftServer.getPlayerList().getPlayerCount()); // Spigot - always use real player count
|
||||
playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
|
||||
|
||||
ServerPing ping = new ServerPing();
|
||||
--
|
||||
1.8.3.2
|
||||
|
Loading…
Reference in New Issue