make EntityData value types guaranteed safe at compile time using generics
This commit is contained in:
parent
3714bafbb4
commit
f6f861a652
5 changed files with 18 additions and 15 deletions
|
@ -3,10 +3,8 @@ package lol.pyr.znpcsplus.metadata;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
|
||||
public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
||||
|
||||
@Override
|
||||
public EntityData cape(boolean enabled) {
|
||||
return createCape(16, enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package lol.pyr.znpcsplus.metadata;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import lol.pyr.znpcsplus.util.list.ListUtil;
|
||||
|
@ -49,4 +50,8 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
protected EntityData createCape(int index, boolean enabled) {
|
||||
return newEntityData(index, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
||||
}
|
||||
|
||||
protected <T> EntityData newEntityData(int index, EntityDataType<T> type, T value) {
|
||||
return new EntityData(index, type, value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue