Use concurrent map instead of copyonwrite set for player's viewable entities

This commit is contained in:
themode 2021-03-26 08:49:27 +01:00
parent e9d76cc742
commit c6c720e0c7

View File

@ -64,6 +64,7 @@ import org.jetbrains.annotations.Nullable;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -81,7 +82,7 @@ public class Player extends LivingEntity implements CommandSender {
private String username; private String username;
protected final PlayerConnection playerConnection; protected final PlayerConnection playerConnection;
// All the entities that this player can see // All the entities that this player can see
protected final Set<Entity> viewableEntities = new CopyOnWriteArraySet<>(); protected final Set<Entity> viewableEntities = ConcurrentHashMap.newKeySet();
private int latency; private int latency;
private JsonMessage displayName; private JsonMessage displayName;