mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-30 05:53:57 +01:00
Change our data structures to use concurrent equivalents, netty is multi-threaded.
This commit is contained in:
parent
63970c6d82
commit
e7f85e67f6
@ -11,12 +11,12 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ProtocolPipeline extends Protocol {
|
public class ProtocolPipeline extends Protocol {
|
||||||
LinkedList<Protocol> protocolList;
|
List<Protocol> protocolList;
|
||||||
private UserConnection userConnection;
|
private UserConnection userConnection;
|
||||||
|
|
||||||
public ProtocolPipeline(UserConnection userConnection) {
|
public ProtocolPipeline(UserConnection userConnection) {
|
||||||
@ -26,9 +26,9 @@ public class ProtocolPipeline extends Protocol {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
protocolList = new LinkedList<>();
|
protocolList = new CopyOnWriteArrayList<>();
|
||||||
// This is a pipeline so we register basic pipes
|
// This is a pipeline so we register basic pipes
|
||||||
protocolList.addLast(ProtocolRegistry.BASE_PROTOCOL);
|
protocolList.add(ProtocolRegistry.BASE_PROTOCOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,7 +54,7 @@ public class ProtocolPipeline extends Protocol {
|
|||||||
*/
|
*/
|
||||||
public void add(Protocol protocol) {
|
public void add(Protocol protocol) {
|
||||||
if (protocolList != null) {
|
if (protocolList != null) {
|
||||||
protocolList.addLast(protocol);
|
protocolList.add(protocol);
|
||||||
protocol.init(userConnection);
|
protocol.init(userConnection);
|
||||||
} else {
|
} else {
|
||||||
throw new NullPointerException("Tried to add protocol to early");
|
throw new NullPointerException("Tried to add protocol to early");
|
||||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
|||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
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 us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class EntityTracker extends StoredObject {
|
public class EntityTracker extends StoredObject {
|
||||||
private final Map<Integer, UUID> uuidMap = new HashMap<>();
|
private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>();
|
||||||
private final Map<Integer, EntityType> clientEntityTypes = new HashMap<>();
|
private final Map<Integer, EntityType> clientEntityTypes = new ConcurrentHashMap<>();
|
||||||
private final Map<Integer, Integer> vehicleMap = new HashMap<>();
|
private final Map<Integer, Integer> vehicleMap = new ConcurrentHashMap<>();
|
||||||
private final Map<Integer, BossBar> bossBarMap = new HashMap<>();
|
private final Map<Integer, BossBar> bossBarMap = new ConcurrentHashMap<>();
|
||||||
private final Set<Integer> validBlocking = new HashSet<>();
|
private final Set<Integer> validBlocking = Sets.newConcurrentHashSet();
|
||||||
private final Set<Integer> knownHolograms = new HashSet<>();
|
private final Set<Integer> knownHolograms = Sets.newConcurrentHashSet();
|
||||||
private final Cache<Position, Material> blockInteractions = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(250, TimeUnit.MILLISECONDS).build();
|
private final Cache<Position, Material> blockInteractions = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(250, TimeUnit.MILLISECONDS).build();
|
||||||
@Setter
|
@Setter
|
||||||
private boolean blocking = false;
|
private boolean blocking = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user