geforkt von Mirrors/Paper
Use fetched GameProfile for getOfflinePlayer(String)
When getting an OfflinePlayer by name we lookup their UUID and then use that to fetch the OfflinePlayer. If the player has not played on this server before the resulting OfflinePlayer will return null for getName(). As this is unintuitive we now create the OfflinePlayer directly using the profile we looked up and make OfflinePlayer prefer that data.
Dieser Commit ist enthalten in:
Ursprung
8f771c7378
Commit
7b409ed4e9
@ -49,6 +49,11 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||||||
return player.getName();
|
return player.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This might not match lastKnownName but if not it should be more correct
|
||||||
|
if (profile.getName() != null) {
|
||||||
|
return profile.getName();
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagCompound data = getBukkitData();
|
NBTTagCompound data = getBukkitData();
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
@ -1260,14 +1260,22 @@ public final class CraftServer implements Server {
|
|||||||
public OfflinePlayer getOfflinePlayer(String name) {
|
public OfflinePlayer getOfflinePlayer(String name) {
|
||||||
Validate.notNull(name, "Name cannot be null");
|
Validate.notNull(name, "Name cannot be null");
|
||||||
|
|
||||||
// This is potentially blocking :(
|
OfflinePlayer result = getPlayerExact(name);
|
||||||
GameProfile profile = MinecraftServer.getServer().getUserCache().a(name);
|
if (result == null) {
|
||||||
if (profile == null) {
|
// This is potentially blocking :(
|
||||||
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
GameProfile profile = MinecraftServer.getServer().getUserCache().a(name);
|
||||||
return getOfflinePlayer(new GameProfile(java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
|
if (profile == null) {
|
||||||
|
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
||||||
|
result = getOfflinePlayer(new GameProfile(java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
|
||||||
|
} else {
|
||||||
|
// Use the GameProfile even when we get a UUID so we ensure we still have a name
|
||||||
|
result = getOfflinePlayer(profile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offlinePlayers.remove(result.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return getOfflinePlayer(profile.getId());
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer(java.util.UUID id) {
|
public OfflinePlayer getOfflinePlayer(java.util.UUID id) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren