diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java index dd749e645..fd97e4620 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java @@ -11,12 +11,12 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo; import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; public class ProtocolPipeline extends Protocol { - LinkedList protocolList; + List protocolList; private UserConnection userConnection; public ProtocolPipeline(UserConnection userConnection) { @@ -26,9 +26,9 @@ public class ProtocolPipeline extends Protocol { @Override protected void registerPackets() { - protocolList = new LinkedList<>(); + protocolList = new CopyOnWriteArrayList<>(); // This is a pipeline so we register basic pipes - protocolList.addLast(ProtocolRegistry.BASE_PROTOCOL); + protocolList.add(ProtocolRegistry.BASE_PROTOCOL); } @Override @@ -54,7 +54,7 @@ public class ProtocolPipeline extends Protocol { */ public void add(Protocol protocol) { if (protocolList != null) { - protocolList.addLast(protocol); + protocolList.add(protocol); protocol.init(userConnection); } else { throw new NullPointerException("Tried to add protocol to early"); diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java index 3caf9e55c..65d0d6155 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java @@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.common.collect.Sets; import io.netty.buffer.ByteBuf; import lombok.Getter; import lombok.Setter; @@ -26,16 +27,17 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @Getter public class EntityTracker extends StoredObject { - private final Map uuidMap = new HashMap<>(); - private final Map clientEntityTypes = new HashMap<>(); - private final Map vehicleMap = new HashMap<>(); - private final Map bossBarMap = new HashMap<>(); - private final Set validBlocking = new HashSet<>(); - private final Set knownHolograms = new HashSet<>(); + private final Map uuidMap = new ConcurrentHashMap<>(); + private final Map clientEntityTypes = new ConcurrentHashMap<>(); + private final Map vehicleMap = new ConcurrentHashMap<>(); + private final Map bossBarMap = new ConcurrentHashMap<>(); + private final Set validBlocking = Sets.newConcurrentHashSet(); + private final Set knownHolograms = Sets.newConcurrentHashSet(); private final Cache blockInteractions = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(250, TimeUnit.MILLISECONDS).build(); @Setter private boolean blocking = false;