testserver/CraftBukkit-Patches/0102-Fix-Ping-Player-Sample...

71 lines
3.6 KiB
Diff

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