mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 19:12:22 +01:00
Use the servers built in UUID map for player lookups
This commit is contained in:
parent
657e0890dc
commit
6c0aedf367
1 changed files with 8 additions and 18 deletions
|
@ -44,14 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return super.remove(key instanceof String ? ((String) key).toLowerCase() : key);
|
+ return super.remove(key instanceof String ? ((String) key).toLowerCase() : key);
|
||||||
+ }
|
+ }
|
||||||
+ };
|
+ };
|
||||||
+ public final Map<UUID, EntityPlayer> uuidMap = new java.util.HashMap<UUID, EntityPlayer>() {
|
|
||||||
+ @Override
|
|
||||||
+ public EntityPlayer get(Object key) {
|
|
||||||
+ // put the .playerConnection check done in other places here
|
|
||||||
+ EntityPlayer player = super.get(key instanceof String ? ((String) key).toLowerCase() : key);
|
|
||||||
+ return (player != null && player.playerConnection != null) ? player : null;
|
|
||||||
+ }
|
|
||||||
+ };
|
|
||||||
+ // PaperSpigot end
|
+ // PaperSpigot end
|
||||||
public final Map f = Maps.newHashMap();
|
public final Map f = Maps.newHashMap();
|
||||||
private final GameProfileBanList k;
|
private final GameProfileBanList k;
|
||||||
|
@ -61,7 +53,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public void onPlayerJoin(EntityPlayer entityplayer) {
|
public void onPlayerJoin(EntityPlayer entityplayer) {
|
||||||
this.players.add(entityplayer);
|
this.players.add(entityplayer);
|
||||||
+ this.playerMap.put(entityplayer.getName(), entityplayer); // PaperSpigot
|
+ this.playerMap.put(entityplayer.getName(), entityplayer); // PaperSpigot
|
||||||
+ this.uuidMap.put(entityplayer.getUniqueID(), entityplayer); // PaperSpigot
|
|
||||||
this.f.put(entityplayer.getUniqueID(), entityplayer);
|
this.f.put(entityplayer.getUniqueID(), entityplayer);
|
||||||
// this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below
|
// this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below
|
||||||
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
|
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
|
||||||
|
@ -69,7 +60,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
worldserver.kill(entityplayer);
|
worldserver.kill(entityplayer);
|
||||||
worldserver.getPlayerChunkMap().removePlayer(entityplayer);
|
worldserver.getPlayerChunkMap().removePlayer(entityplayer);
|
||||||
this.players.remove(entityplayer);
|
this.players.remove(entityplayer);
|
||||||
+ this.uuidMap.remove(entityplayer.getUniqueID()); // PaperSpigot
|
|
||||||
+ this.playerMap.remove(entityplayer.getName()); // PaperSpigot
|
+ this.playerMap.remove(entityplayer.getName()); // PaperSpigot
|
||||||
this.f.remove(entityplayer.getUniqueID());
|
this.f.remove(entityplayer.getUniqueID());
|
||||||
this.o.remove(entityplayer.getUniqueID());
|
this.o.remove(entityplayer.getUniqueID());
|
||||||
|
@ -88,11 +78,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
entityplayer = (EntityPlayer) iterator.next();
|
entityplayer = (EntityPlayer) iterator.next();
|
||||||
+ */
|
+ */
|
||||||
+ if ((entityplayer = uuidMap.get(uuid)) != null) {
|
+ if ((entityplayer = this.a(uuid)) != null) {
|
||||||
+ // PaperSpigot end
|
savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
|
||||||
entityplayer.playerConnection.disconnect("You logged in from another location");
|
entityplayer.playerConnection.disconnect("You logged in from another location");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
-
|
-
|
||||||
- return null;
|
- return null;
|
||||||
+ // PaperSpigot - Improved player lookup, replace entire method
|
+ // PaperSpigot - Improved player lookup, replace entire method
|
||||||
+ final EntityPlayer playerEntity = server.getHandle().uuidMap.get(getUniqueId());
|
+ final EntityPlayer playerEntity = server.getHandle().a(getUniqueId());
|
||||||
+ return playerEntity != null ? playerEntity.getBukkitEntity() : null;
|
+ return playerEntity != null ? playerEntity.getBukkitEntity() : null;
|
||||||
+ // PaperSpigot end
|
+ // PaperSpigot end
|
||||||
}
|
}
|
||||||
|
@ -177,8 +166,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- }
|
- }
|
||||||
- }
|
- }
|
||||||
- return false;
|
- return false;
|
||||||
+ return server.getHandle().uuidMap.get(getUniqueId()) != null; // PaperSpigot - replace whole method
|
+ return server.getHandle().a(getUniqueId()) != null; // PaperSpigot - replace whole method
|
||||||
}
|
}
|
||||||
|
|
||||||
public InetSocketAddress getAddress() {
|
public InetSocketAddress getAddress() {
|
||||||
--
|
--
|
||||||
|
1.9.4.msysgit.2
|
||||||
|
|
Loading…
Reference in a new issue