mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 02:25:19 +01:00
use spaces
This commit is contained in:
parent
44183f19cd
commit
2442520ef3
@ -2,8 +2,8 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
public interface IEntityType {
|
||||
|
||||
int getId();
|
||||
int getId();
|
||||
|
||||
IEntityType getParent();
|
||||
IEntityType getParent();
|
||||
|
||||
}
|
||||
|
@ -14,37 +14,37 @@ import java.util.logging.Logger;
|
||||
|
||||
public abstract class MetadataRewriter<T extends IEntityType> {
|
||||
|
||||
public final void handleMetadata(int entityId, T type, List<Metadata> metadatas, UserConnection connection) {
|
||||
Map<Integer, Metadata> metadataMap = new HashMap<>(metadatas.size());
|
||||
for (Metadata metadata : metadatas) {
|
||||
metadataMap.put(metadata.getId(), metadata);
|
||||
}
|
||||
public final void handleMetadata(int entityId, T type, List<Metadata> metadatas, UserConnection connection) {
|
||||
Map<Integer, Metadata> 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<Metadata> metadatas, UserConnection connection) throws Exception {}
|
||||
protected void handleMetadata(int entityId, T type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {}
|
||||
|
||||
protected void handleMetadata(int entityId, T type, Metadata metadata, List<Metadata> metadatas, Map<Integer, Metadata> metadataMap, UserConnection connection) throws Exception {
|
||||
handleMetadata(entityId, type, metadata, metadatas, connection);
|
||||
}
|
||||
protected void handleMetadata(int entityId, T type, Metadata metadata, List<Metadata> metadatas, Map<Integer, Metadata> metadataMap, UserConnection connection) throws Exception {
|
||||
handleMetadata(entityId, type, metadata, metadatas, connection);
|
||||
}
|
||||
}
|
||||
|
@ -12,36 +12,36 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class EntityTracker<T extends IEntityType> extends StoredObject implements ExternalJoinGameListener {
|
||||
private final Map<Integer, T> clientEntityTypes = new ConcurrentHashMap<>();
|
||||
@Getter
|
||||
@Setter
|
||||
private int clientEntityId;
|
||||
private final T playerType;
|
||||
private final Map<Integer, T> 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<T> getEntity(int entityId) {
|
||||
return Optional.fromNullable(clientEntityTypes.get(entityId));
|
||||
}
|
||||
public Optional<T> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user