3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Remove uuid tracking

Dieser Commit ist enthalten in:
creeper123123321 2019-02-13 17:00:01 -02:00
Ursprung 35bb80d67a
Commit 11b25151f7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1

Datei anzeigen

@ -1,9 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Maps;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_14Types; import us.myles.ViaVersion.api.entities.Entity1_14Types;
@ -14,19 +11,16 @@ import java.util.concurrent.ConcurrentHashMap;
public class EntityTracker extends StoredObject { public class EntityTracker extends StoredObject {
private final Map<Integer, Entity1_14Types.EntityType> clientEntityTypes = new ConcurrentHashMap<>(); private final Map<Integer, Entity1_14Types.EntityType> clientEntityTypes = new ConcurrentHashMap<>();
private final BiMap<UUID, Integer> uuidToId = Maps.synchronizedBiMap(HashBiMap.<UUID, Integer>create());
public EntityTracker(UserConnection user) { public EntityTracker(UserConnection user) {
super(user); super(user);
} }
public void removeEntity(int entityId) { public void removeEntity(int entityId) {
uuidToId.inverse().remove(entityId);
clientEntityTypes.remove(entityId); clientEntityTypes.remove(entityId);
} }
public void addEntity(int entityId, UUID uuid, Entity1_14Types.EntityType type) { public void addEntity(int entityId, UUID uuid, Entity1_14Types.EntityType type) {
uuidToId.forcePut(uuid, entityId);
clientEntityTypes.put(entityId, type); clientEntityTypes.put(entityId, type);
} }
@ -37,8 +31,4 @@ public class EntityTracker extends StoredObject {
public Optional<Entity1_14Types.EntityType> get(int id) { public Optional<Entity1_14Types.EntityType> get(int id) {
return Optional.fromNullable(clientEntityTypes.get(id)); return Optional.fromNullable(clientEntityTypes.get(id));
} }
public Optional<UUID> getUUID(int id) {
return Optional.fromNullable(uuidToId.inverse().get(id));
}
} }