13
0
geforkt von Mirrors/Paper

[Bleeding] Fixed EntityType errors. Fixes BUKKIT-800

By: Feildmaster <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-02-23 14:13:33 -06:00
Ursprung 80e59821f3
Commit 2f03671311

Datei anzeigen

@ -1,6 +1,5 @@
package org.bukkit.entity; package org.bukkit.entity;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -18,7 +17,7 @@ public enum EntityType {
ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14), ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14),
ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15), ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15),
PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20), PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20),
FALLING_BLOCK("FallingSand", FallingSand.class, 21, false), FALLING_BLOCK("FallingBlock", FallingSand.class, 21, false),
MINECART("Minecart", Minecart.class, 40), MINECART("Minecart", Minecart.class, 40),
BOAT("Boat", Boat.class, 41), BOAT("Boat", Boat.class, 41),
CREEPER("Creeper", Creeper.class, 50), CREEPER("Creeper", Creeper.class, 50),
@ -70,10 +69,11 @@ public enum EntityType {
private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>(); private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>();
static { static {
for (EntityType type : EnumSet.allOf(EntityType.class)) { for (EntityType type : values()) {
NAME_MAP.put(type.name, type); if (type.name != null) {
NAME_MAP.put(type.name(), type); NAME_MAP.put(type.name.toLowerCase(), type);
if (type.typeId != 0) { }
if (type.typeId > 0) {
ID_MAP.put(type.typeId, type); ID_MAP.put(type.typeId, type);
} }
} }
@ -88,7 +88,9 @@ public enum EntityType {
this.clazz = clazz; this.clazz = clazz;
this.typeId = (short) typeId; this.typeId = (short) typeId;
this.independent = independent; this.independent = independent;
this.living = LivingEntity.class.isAssignableFrom(clazz); if (clazz != null) {
this.living = LivingEntity.class.isAssignableFrom(clazz);
}
} }
public String getName() { public String getName() {
@ -104,7 +106,10 @@ public enum EntityType {
} }
public static EntityType fromName(String name) { public static EntityType fromName(String name) {
return NAME_MAP.get(name); if (name == null) {
return null;
}
return NAME_MAP.get(name.toLowerCase());
} }
public static EntityType fromId(int id) { public static EntityType fromId(int id) {