diff --git a/common/src/main/java/us/myles/ViaVersion/api/entities/IEntityType.java b/common/src/main/java/us/myles/ViaVersion/api/entities/IEntityType.java index b8c6ee35b..dac772fe6 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/entities/IEntityType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/entities/IEntityType.java @@ -2,8 +2,8 @@ package us.myles.ViaVersion.api.entities; public interface IEntityType { - int getId(); + int getId(); - IEntityType getParent(); + IEntityType getParent(); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java index cfe89827d..2769d8162 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java @@ -14,37 +14,37 @@ import java.util.logging.Logger; public abstract class MetadataRewriter { - public final void handleMetadata(int entityId, T type, List metadatas, UserConnection connection) { - Map metadataMap = new HashMap<>(metadatas.size()); - for (Metadata metadata : metadatas) { - metadataMap.put(metadata.getId(), metadata); - } + public final void handleMetadata(int entityId, T type, List metadatas, UserConnection connection) { + Map metadataMap = new HashMap<>(metadatas.size()); + for (Metadata metadata : metadatas) { + metadataMap.put(metadata.getId(), metadata); + } - metadataMap = Collections.unmodifiableMap(metadataMap); + metadataMap = Collections.unmodifiableMap(metadataMap); - for (Metadata metadata : new ArrayList<>(metadatas)) { - int oldId = metadata.getId(); - try { - handleMetadata(entityId, type, metadata, metadatas, metadataMap, connection); - } catch (Exception e) { - metadatas.remove(metadata); - if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { - Logger logger = Via.getPlatform().getLogger(); + for (Metadata metadata : new ArrayList<>(metadatas)) { + int oldId = metadata.getId(); + try { + handleMetadata(entityId, type, metadata, metadatas, metadataMap, connection); + } catch (Exception e) { + metadatas.remove(metadata); + if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { + Logger logger = Via.getPlatform().getLogger(); - logger.warning("An error occurred with entity metadata handler"); - logger.warning("This is most likely down to one of your plugins sending bad datawatchers. Please test if this occurs without any plugins except ViaVersion before reporting it on GitHub"); - logger.warning("Also make sure that all your plugins are compatible with your server version."); - logger.warning("Entity type: " + type); - logger.warning("Metadata: " + metadata); - e.printStackTrace(); - } - } - } - } + logger.warning("An error occurred with entity metadata handler"); + logger.warning("This is most likely down to one of your plugins sending bad datawatchers. Please test if this occurs without any plugins except ViaVersion before reporting it on GitHub"); + logger.warning("Also make sure that all your plugins are compatible with your server version."); + logger.warning("Entity type: " + type); + logger.warning("Metadata: " + metadata); + e.printStackTrace(); + } + } + } + } - protected void handleMetadata(int entityId, T type, Metadata metadata, List metadatas, UserConnection connection) throws Exception {} + protected void handleMetadata(int entityId, T type, Metadata metadata, List metadatas, UserConnection connection) throws Exception {} - protected void handleMetadata(int entityId, T type, Metadata metadata, List metadatas, Map metadataMap, UserConnection connection) throws Exception { - handleMetadata(entityId, type, metadata, metadatas, connection); - } + protected void handleMetadata(int entityId, T type, Metadata metadata, List metadatas, Map metadataMap, UserConnection connection) throws Exception { + handleMetadata(entityId, type, metadata, metadatas, connection); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/api/storage/EntityTracker.java index e9791cd3a..2c2751414 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/storage/EntityTracker.java +++ b/common/src/main/java/us/myles/ViaVersion/api/storage/EntityTracker.java @@ -12,36 +12,36 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public abstract class EntityTracker extends StoredObject implements ExternalJoinGameListener { - private final Map clientEntityTypes = new ConcurrentHashMap<>(); - @Getter - @Setter - private int clientEntityId; - private final T playerType; + private final Map clientEntityTypes = new ConcurrentHashMap<>(); + @Getter + @Setter + private int clientEntityId; + private final T playerType; - protected EntityTracker(UserConnection user, T playerType) { - super(user); - this.playerType = playerType; - } + protected EntityTracker(UserConnection user, T playerType) { + super(user); + this.playerType = playerType; + } - public void removeEntity(int entityId) { - clientEntityTypes.remove(entityId); - } + public void removeEntity(int entityId) { + clientEntityTypes.remove(entityId); + } - public void addEntity(int entityId, T type) { - clientEntityTypes.put(entityId, type); - } + public void addEntity(int entityId, T type) { + clientEntityTypes.put(entityId, type); + } - public boolean hasEntity(int entityId) { - return clientEntityTypes.containsKey(entityId); - } + public boolean hasEntity(int entityId) { + return clientEntityTypes.containsKey(entityId); + } - public Optional getEntity(int entityId) { - return Optional.fromNullable(clientEntityTypes.get(entityId)); - } + public Optional getEntity(int entityId) { + return Optional.fromNullable(clientEntityTypes.get(entityId)); + } - @Override - public void onExternalJoinGame(int playerEntityId) { - clientEntityId = playerEntityId; - clientEntityTypes.put(playerEntityId, playerType); - } + @Override + public void onExternalJoinGame(int playerEntityId) { + clientEntityId = playerEntityId; + clientEntityTypes.put(playerEntityId, playerType); + } }