diff options
author | EdGruberman <ed@rjump.com> | 2012-08-09 09:27:40 -0700 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-11-17 15:06:18 -0600 |
commit | 293474d99b4802bd38e6794b484d91212e8893c8 (patch) | |
tree | 447358bdeb1e3cfd5ca6a79645adbd33af9efdc7 /src/main/java | |
parent | 20c074ec6c71863d50165338999795a226435254 (diff) | |
download | craftbukkit-293474d99b4802bd38e6794b484d91212e8893c8.tar craftbukkit-293474d99b4802bd38e6794b484d91212e8893c8.tar.gz craftbukkit-293474d99b4802bd38e6794b484d91212e8893c8.tar.lz craftbukkit-293474d99b4802bd38e6794b484d91212e8893c8.tar.xz craftbukkit-293474d99b4802bd38e6794b484d91212e8893c8.zip |
[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.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0cb25a61..e757b437 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -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); } |