1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package org.bukkit.entity;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.World;
public enum EntityType {
// These strings MUST match the strings in nms.EntityTypes and are case sensitive.
DROPPED_ITEM("Item", Item.class, 1, false),
EXPERIENCE_ORB("XPOrb", ExperienceOrb.class, 2),
PAINTING("Painting", Painting.class, 9),
ARROW("Arrow", Arrow.class, 10),
SNOWBALL("Snowball", Snowball.class, 11),
FIREBALL("Fireball", Fireball.class, 12),
SMALL_FIREBALL("SmallFireball", SmallFireball.class, 13),
ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14),
ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15),
PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20),
FALLING_BLOCK("FallingSand", FallingSand.class, 21, false),
MINECART("Minecart", Minecart.class, 40),
BOAT("Boat", Boat.class, 41),
CREEPER("Creeper", Creeper.class, 50),
SKELETON("Skeleton", Skeleton.class, 51),
SPIDER("Spider", Spider.class, 52),
GIANT("Giant", Giant.class, 53),
ZOMBIE("Zombie", Zombie.class, 54),
SLIME("Slime", Slime.class, 55),
GHAST("Ghast", Ghast.class, 56),
PIG_ZOMBIE("PigZombie", PigZombie.class, 57),
ENDERMAN("Enderman", Enderman.class, 58),
CAVE_SPIDER("CaveSpider", CaveSpider.class, 59),
SILVERFISH("Silverfish", Silverfish.class, 60),
BLAZE("Blaze", Blaze.class, 61),
MAGMA_CUBE("LavaSlime", MagmaCube.class, 62),
ENDER_DRAGON("EnderDragon", EnderDragon.class, 63),
PIG("Pig", Pig.class, 90),
SHEEP("Sheep", Sheep.class, 91),
COW("Cow", Cow.class, 92),
CHICKEN("Chicken", Chicken.class, 93),
SQUID("Squid", Squid.class, 94),
WOLF("Wolf", Wolf.class, 95),
MUSHROOM_COW("MushroomCow", MushroomCow.class, 96),
SNOWMAN("SnowMan", Snowman.class, 97),
VILLAGER("Villager", Villager.class, 120),
ENDER_CRYSTAL("EnderCrystal", EnderCrystal.class, 200),
// These don't have an entity ID in nms.EntityTypes.
SPLASH_POTION(null, ThrownPotion.class, -1, false),
EGG(null, Egg.class, -1, false),
FISHING_HOOK(null, Fish.class, -1, false),
/**
* Spawn with {@link World#strikeLightning(org.bukkit.Location)}.
*/
LIGHTNING(null, LightningStrike.class, -1, false),
WEATHER(null, Weather.class, -1, false),
PLAYER(null, Player.class, -1, false),
COMPLEX_PART(null, ComplexEntityPart.class, -1, false),
/**
* An unknown entity without an Entity Class
*/
UNKNOWN(null, null, -1, false);
private String name;
private Class<? extends Entity> clazz;
private short typeId;
private boolean independent, living;
private static final Map<String, EntityType> NAME_MAP = new HashMap<String, EntityType>();
private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>();
static {
for (EntityType type : EnumSet.allOf(EntityType.class)) {
NAME_MAP.put(type.name, type);
NAME_MAP.put(type.name(), type);
if (type.typeId != 0) {
ID_MAP.put(type.typeId, type);
}
}
}
private EntityType(String name, Class<? extends Entity> clazz, int typeId) {
this(name, clazz, typeId, true);
}
private EntityType(String name, Class<? extends Entity> clazz, int typeId, boolean independent) {
this.name = name;
this.clazz = clazz;
this.typeId = (short) typeId;
this.independent = independent;
this.living = LivingEntity.class.isAssignableFrom(clazz);
}
public String getName() {
return name;
}
public Class<? extends Entity> getEntityClass() {
return clazz;
}
public short getTypeId() {
return typeId;
}
public static EntityType fromName(String name) {
return NAME_MAP.get(name);
}
public static EntityType fromId(int id) {
if (id > Short.MAX_VALUE) {
return null;
}
return ID_MAP.get((short) id);
}
/**
* Some entities cannot be spawned using {@link World#spawn(org.bukkit.Location, EntityType)}, usually
* because they require additional information in order to spawn.
* @return False if the entity type cannot be spawned
*/
public boolean isSpawnable() {
return independent;
}
public boolean isAlive() {
return living;
}
}
|