geforkt von Mirrors/Paper
[Bleeding] Use case from player data for OfflinePlayer. Fixes BUKKIT-519
If a plugin looks up a player that is offline they may not know the correct capitalization for the name. In this case they're likely to get it wrong and since we cache the result even after the player joins the server all future request for an OfflinePlayer will return one with incorrect case. When looking up a player who has played on the server before we can get the correct case from the player data file saved by the server. If the player has never played before this point we cannot do anything and will still have the same issue but this is not a solvable problem.
Dieser Commit ist enthalten in:
Ursprung
20c074ec6c
Commit
293474d99b
@ -1019,6 +1019,10 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer(String name) {
|
public OfflinePlayer getOfflinePlayer(String name) {
|
||||||
|
return getOfflinePlayer(name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OfflinePlayer getOfflinePlayer(String name, boolean search) {
|
||||||
OfflinePlayer result = getPlayerExact(name);
|
OfflinePlayer result = getPlayerExact(name);
|
||||||
String lname = name.toLowerCase();
|
String lname = name.toLowerCase();
|
||||||
|
|
||||||
@ -1026,6 +1030,17 @@ public final class CraftServer implements Server {
|
|||||||
result = offlinePlayers.get(lname);
|
result = offlinePlayers.get(lname);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
if (search) {
|
||||||
|
WorldNBTStorage storage = (WorldNBTStorage) console.worlds.get(0).getDataManager();
|
||||||
|
for (String dat : storage.getPlayerDir().list(new DatFileFilter())) {
|
||||||
|
String datName = dat.substring(0, dat.length() - 4);
|
||||||
|
if (datName.equalsIgnoreCase(name)) {
|
||||||
|
name = datName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = new CraftOfflinePlayer(this, name);
|
result = new CraftOfflinePlayer(this, name);
|
||||||
offlinePlayers.put(lname, result);
|
offlinePlayers.put(lname, result);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren