mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +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.
This commit is contained in:
parent
20c074ec6c
commit
293474d99b
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user