Fix Ping Player Sample to bring it back in line with Vanilla behaviour. The behaviour which Bukkit introduced recently is broken on larger servers as it introduces too many players to the list.

This commit is contained in:
md_5 2014-01-26 12:14:05 +11:00
parent 14c0d5cba9
commit 8832052c84
1 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,61 @@
From d8be3082b4cc82d525e1152efc58bced681890b1 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 a549a95..e967d17 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;
// Spigot end
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
@@ -560,15 +561,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..8203fbd 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();
--
1.8.3.2