better property definitions
This commit is contained in:
parent
7fade89b8d
commit
85d2b852f9
1 changed files with 16 additions and 12 deletions
|
@ -1,16 +1,19 @@
|
|||
package lol.pyr.znpcsplus.npc;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class NPCType {
|
||||
private final static ImmutableList<NPCType> npcTypes;
|
||||
private final static Set<NPCType> npcTypes;
|
||||
|
||||
public static List<NPCType> values() {
|
||||
public static Set<NPCType> values() {
|
||||
return npcTypes;
|
||||
}
|
||||
|
||||
|
@ -19,7 +22,10 @@ public class NPCType {
|
|||
|
||||
public NPCType(EntityType type, NPCProperty<?>... allowedProperties) {
|
||||
this.type = type;
|
||||
this.allowedProperties = Set.of(allowedProperties);
|
||||
ArrayList<NPCProperty<?>> list = new ArrayList<>(List.of(allowedProperties));
|
||||
list.add(NPCProperty.FIRE);
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) list.add(NPCProperty.GLOW);
|
||||
this.allowedProperties = Set.copyOf(list);
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
|
@ -31,13 +37,11 @@ public class NPCType {
|
|||
}
|
||||
|
||||
static {
|
||||
ImmutableList.Builder<NPCType> builder = new ImmutableList.Builder<>();
|
||||
|
||||
builder.add(new NPCType(EntityTypes.PLAYER, NPCProperty.GLOW, NPCProperty.FIRE, NPCProperty.SKIN, NPCProperty.SKIN_LAYERS));
|
||||
builder.add(new NPCType(EntityTypes.CREEPER, NPCProperty.GLOW, NPCProperty.FIRE));
|
||||
builder.add(new NPCType(EntityTypes.ZOMBIE, NPCProperty.GLOW, NPCProperty.FIRE));
|
||||
builder.add(new NPCType(EntityTypes.SKELETON, NPCProperty.GLOW, NPCProperty.FIRE));
|
||||
|
||||
npcTypes = builder.build();
|
||||
Set<NPCType> set = new HashSet<>();
|
||||
set.add(new NPCType(EntityTypes.PLAYER, NPCProperty.SKIN, NPCProperty.SKIN_LAYERS));
|
||||
set.add(new NPCType(EntityTypes.CREEPER));
|
||||
set.add(new NPCType(EntityTypes.ZOMBIE));
|
||||
set.add(new NPCType(EntityTypes.SKELETON));
|
||||
npcTypes = Set.copyOf(set);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue