mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 21:19:00 +01:00
[Bleeding] Make sure we don't keep stale references to vanished players.
This commit is contained in:
parent
d8ca2401ff
commit
7ff8c17568
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user