From 2f03671311980b9741ced729f78ba617751d5d6a Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 23 Feb 2012 14:13:33 -0600 Subject: [PATCH] [Bleeding] Fixed EntityType errors. Fixes BUKKIT-800 By: Feildmaster --- .../java/org/bukkit/entity/EntityType.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index db9f2869ef..420bccb014 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -1,6 +1,5 @@ package org.bukkit.entity; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -18,7 +17,7 @@ public enum EntityType { 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), + FALLING_BLOCK("FallingBlock", FallingSand.class, 21, false), MINECART("Minecart", Minecart.class, 40), BOAT("Boat", Boat.class, 41), CREEPER("Creeper", Creeper.class, 50), @@ -70,10 +69,11 @@ public enum EntityType { private static final Map ID_MAP = new HashMap(); static { - for (EntityType type : EnumSet.allOf(EntityType.class)) { - NAME_MAP.put(type.name, type); - NAME_MAP.put(type.name(), type); - if (type.typeId != 0) { + for (EntityType type : values()) { + if (type.name != null) { + NAME_MAP.put(type.name.toLowerCase(), type); + } + if (type.typeId > 0) { ID_MAP.put(type.typeId, type); } } @@ -88,7 +88,9 @@ public enum EntityType { this.clazz = clazz; this.typeId = (short) typeId; this.independent = independent; - this.living = LivingEntity.class.isAssignableFrom(clazz); + if (clazz != null) { + this.living = LivingEntity.class.isAssignableFrom(clazz); + } } public String getName() { @@ -104,7 +106,10 @@ public enum EntityType { } 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) {