diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-25 04:21:35 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-25 04:21:35 +0100 |
commit | 8f8c62b71b76675903405df4f7f11edc1a7c6db6 (patch) | |
tree | 90441b96689a146095faa80f832255fc9e0d443e /src/main/java/org | |
parent | a1f8d3fd479bdf0e1860637e464a57efbc82c7cd (diff) | |
download | craftbukkit-8f8c62b71b76675903405df4f7f11edc1a7c6db6.tar craftbukkit-8f8c62b71b76675903405df4f7f11edc1a7c6db6.tar.gz craftbukkit-8f8c62b71b76675903405df4f7f11edc1a7c6db6.tar.lz craftbukkit-8f8c62b71b76675903405df4f7f11edc1a7c6db6.tar.xz craftbukkit-8f8c62b71b76675903405df4f7f11edc1a7c6db6.zip |
Ensure there's only one OfflinePlayer object per actual offline player
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 8bb53fc3..36e66ec2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -6,6 +6,7 @@ import com.avaje.ebean.config.DataSourceConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.SQLitePlatform; import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation; +import com.google.common.collect.MapMaker; import net.minecraft.server.IWorldAccess; import org.bukkit.World.Environment; import org.bukkit.command.*; @@ -89,6 +90,7 @@ public final class CraftServer implements Server { private final Map<String, World> worlds = new LinkedHashMap<String, World>(); private final Configuration configuration; private final Yaml yaml = new Yaml(new SafeConstructor()); + private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap(); public CraftServer(MinecraftServer console, ServerConfigurationManager server) { this.console = console; @@ -790,9 +792,17 @@ public final class CraftServer implements Server { public OfflinePlayer getOfflinePlayer(String name) { OfflinePlayer result = getPlayerExact(name); + String lname = name.toLowerCase(); if (result == null) { - result = new CraftOfflinePlayer(this, name); + result = offlinePlayers.get(lname); + + if (result == null) { + result = new CraftOfflinePlayer(this, name); + offlinePlayers.put(lname, result); + } + } else { + offlinePlayers.remove(lname); } return result; |