fix(meta): update EntityData type to be generic in EntityMeta and Metadata

This commit is contained in:
Felipe Paschoal Bergamo 2025-07-15 22:40:24 -03:00
parent 49943c9515
commit a4ce05886d
3 changed files with 13 additions and 13 deletions

View file

@ -272,12 +272,12 @@ public class EntityMeta implements EntityMetadataProvider {
} }
@Override @Override
public List<EntityData> entityData(ClientVersion clientVersion) { public @NotNull List<EntityData<?>> entityData(@NotNull ClientVersion clientVersion) {
return metadata.getEntries(); // TODO: Atm this is useless cause of the way the api works. Might change in the future return metadata.getEntries(); // TODO: Atm this is useless cause of the way the api works. Might change in the future
} }
@Override @Override
public List<EntityData> entityData() { public @NotNull List<EntityData<?>> entityData() {
return metadata.getEntries(); return metadata.getEntries();
} }

View file

@ -19,8 +19,8 @@ public class Metadata {
private final int entityId; private final int entityId;
private volatile boolean notifyAboutChanges = true; private volatile boolean notifyAboutChanges = true;
private final HashMap<Byte, EntityData> notNotifiedChanges = new HashMap<>(); private final HashMap<Byte, EntityData<?>> notNotifiedChanges = new HashMap<>();
private final ConcurrentHashMap<Byte, EntityData> metadataMap = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Byte, EntityData<?>> metadataMap = new ConcurrentHashMap<>();
public Metadata(int entityId) { public Metadata(int entityId) {
this.entityId = entityId; this.entityId = entityId;
@ -47,13 +47,13 @@ public class Metadata {
} }
public <T> T getIndex(byte index, @Nullable T defaultValue) { public <T> T getIndex(byte index, @Nullable T defaultValue) {
EntityData value = this.metadataMap.get(index); EntityData<?> value = this.metadataMap.get(index);
return value != null ? (T) value.getValue() : defaultValue; return value != null ? (T) value.getValue() : defaultValue;
} }
public <T> void setIndex(byte index, @NotNull EntityDataType<T> dataType, T value) { public <T> void setIndex(byte index, @NotNull EntityDataType<T> dataType, T value) {
final EntityData entry = new EntityData(index, dataType, value); final EntityData<?> entry = new EntityData<>(index, dataType, value);
this.metadataMap.put(index, entry); this.metadataMap.put(index, entry);
final Optional<EntityLibAPI<?>> optionalApi = EntityLib.getOptionalApi(); final Optional<EntityLibAPI<?>> optionalApi = EntityLib.getOptionalApi();
@ -75,7 +75,7 @@ public class Metadata {
return; return;
} }
List<EntityData> entries = null; List<EntityData<?>> entries = null;
synchronized (this.notNotifiedChanges) { synchronized (this.notNotifiedChanges) {
this.notifyAboutChanges = notifyAboutChanges; this.notifyAboutChanges = notifyAboutChanges;
if (notifyAboutChanges) { if (notifyAboutChanges) {
@ -96,7 +96,7 @@ public class Metadata {
} }
public void setMetaFromPacket(WrapperPlayServerEntityMetadata wrapper) { public void setMetaFromPacket(WrapperPlayServerEntityMetadata wrapper) {
for (EntityData data : wrapper.getEntityMetadata()) { for (EntityData<?> data : wrapper.getEntityMetadata()) {
metadataMap.put((byte) data.getIndex(), data); metadataMap.put((byte) data.getIndex(), data);
} }
} }
@ -105,7 +105,7 @@ public class Metadata {
return notifyAboutChanges; return notifyAboutChanges;
} }
@NotNull List<EntityData> getEntries() { @NotNull List<EntityData<?>> getEntries() {
return Collections.unmodifiableList(new ArrayList<>(metadataMap.values())); return Collections.unmodifiableList(new ArrayList<>(metadataMap.values()));
} }

View file

@ -1,8 +1,8 @@
[versions] [versions]
adventure = "4.16.0" adventure = "4.22.0"
jetbrains-annotations = "24.0.0" jetbrains-annotations = "26.0.2"
gson = "2.11.0" gson = "2.13.1"
packetevents = "2.7.0" packetevents = "2.9.1"
paper = "1.21-R0.1-SNAPSHOT" paper = "1.21-R0.1-SNAPSHOT"
velocity = "3.3.0-SNAPSHOT" velocity = "3.3.0-SNAPSHOT"
run-paper = "2.3.0" run-paper = "2.3.0"