mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 11:05:13 +01:00
Ensure there's only one OfflinePlayer object per actual offline player
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
af65244ba9
commit
4c3b2cbd0b
1 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,7 @@ import com.avaje.ebean.config.DataSourceConfig;
|
||||||
import com.avaje.ebean.config.ServerConfig;
|
import com.avaje.ebean.config.ServerConfig;
|
||||||
import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||||
import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
||||||
|
import com.google.common.collect.MapMaker;
|
||||||
import net.minecraft.server.IWorldAccess;
|
import net.minecraft.server.IWorldAccess;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.command.*;
|
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 Map<String, World> worlds = new LinkedHashMap<String, World>();
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||||
|
private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap();
|
||||||
|
|
||||||
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
|
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
|
||||||
this.console = console;
|
this.console = console;
|
||||||
|
@ -790,9 +792,17 @@ public final class CraftServer implements Server {
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer(String name) {
|
public OfflinePlayer getOfflinePlayer(String name) {
|
||||||
OfflinePlayer result = getPlayerExact(name);
|
OfflinePlayer result = getPlayerExact(name);
|
||||||
|
String lname = name.toLowerCase();
|
||||||
|
|
||||||
if (result == null) {
|
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;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue