3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00

[Bleeding] Make sure we don't keep stale references to vanished players.

Dieser Commit ist enthalten in:
Travis Watkins 2012-02-09 20:08:00 -06:00 committet von EvilSeph
Ursprung d8ca2401ff
Commit 7ff8c17568

Datei anzeigen

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.MapMaker;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -36,7 +37,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private long lastPlayed = 0; private long lastPlayed = 0;
private boolean hasPlayedBefore = false; private boolean hasPlayedBefore = false;
private Set<String> channels = new HashSet<String>(); private Set<String> channels = new HashSet<String>();
private Set<Player> hiddenPlayers = new HashSet<Player>(); private Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
private int hash = 0; private int hash = 0;
public CraftPlayer(CraftServer server, EntityPlayer entity) { public CraftPlayer(CraftServer server, EntityPlayer entity) {
@ -564,8 +565,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public void hidePlayer(Player player) { public void hidePlayer(Player player) {
if (hiddenPlayers.contains(player)) return; if (hiddenPlayers.containsKey(player.getName())) return;
hiddenPlayers.add(player); hiddenPlayers.put(player.getName(), player);
//remove this player from the hidden player's EntityTrackerEntry //remove this player from the hidden player's EntityTrackerEntry
EntityTracker tracker = ((WorldServer) entity.world).tracker; EntityTracker tracker = ((WorldServer) entity.world).tracker;
@ -580,8 +581,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public void showPlayer(Player player) { public void showPlayer(Player player) {
if (!hiddenPlayers.contains(player)) return; if (!hiddenPlayers.containsKey(player.getName())) return;
hiddenPlayers.remove(player); hiddenPlayers.remove(player.getName());
EntityTracker tracker = ((WorldServer) entity.world).tracker; EntityTracker tracker = ((WorldServer) entity.world).tracker;
EntityPlayer other = ((CraftPlayer) player).getHandle(); EntityPlayer other = ((CraftPlayer) player).getHandle();
@ -594,7 +595,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public boolean canSee(Player player) { public boolean canSee(Player player) {
return !hiddenPlayers.contains(player); return !hiddenPlayers.containsKey(player.getName());
} }
public Map<String, Object> serialize() { public Map<String, Object> serialize() {