Address Serious Issues with Offline Players

Such as name being entirely unresolved! This fixes the whitelist command and no doubt lots more.
This commit is contained in:
md_5 2014-04-12 17:17:26 +10:00
parent 75deb2c530
commit ec9e487811

View File

@ -0,0 +1,48 @@
From 10d02ec6f0dd8e565dfa87b6381031fcabe0ca69 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 12 Apr 2014 17:17:10 +1000
Subject: [PATCH] Address Serious Issues with Offline Players
Such as name being entirely unresolved! This fixes the whitelist command and no doubt lots more.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index bec4134..ecf0fa4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -48,6 +48,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
if (player != null) {
return player.getName();
}
+ // Spigot Start
+ if ( profile != null )
+ {
+ return profile.getName();
+ }
+ // Spigot End
NBTTagCompound data = getBukkitData();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2645c97..c3212ab 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1322,7 +1322,7 @@ public final class CraftServer implements Server {
if (result == null) {
result = offlinePlayers.get(id);
if (result == null) {
- result = new CraftOfflinePlayer(this, new GameProfile(id, null));
+ result = new CraftOfflinePlayer(this, MinecraftServer.getServer().getUserCache().a(id)); // Spigot - this is blocking, but we have no choice!
offlinePlayers.put(id, result);
}
} else {
@@ -1392,6 +1392,7 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getWhitelistedPlayers() {
Set<OfflinePlayer> result = new LinkedHashSet<OfflinePlayer>();
+ Object w = playerList.getWhitelisted();
for (Object name : playerList.getWhitelisted()) {
if (((String)name).length() == 0 || ((String)name).startsWith("#")) {
continue;
--
1.8.3.2