3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

[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:
EdGruberman 2012-08-09 09:27:40 -07:00 committet von Travis Watkins
Ursprung 20c074ec6c
Commit 293474d99b

Datei anzeigen

@ -1019,6 +1019,10 @@ public final class CraftServer implements Server {
}
public OfflinePlayer getOfflinePlayer(String name) {
return getOfflinePlayer(name, true);
}
public OfflinePlayer getOfflinePlayer(String name, boolean search) {
OfflinePlayer result = getPlayerExact(name);
String lname = name.toLowerCase();
@ -1026,6 +1030,17 @@ public final class CraftServer implements Server {
result = offlinePlayers.get(lname);
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);
offlinePlayers.put(lname, result);
}