From 0d52d22bd8964988faaf01b19cfbd38f0fe6a591 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 16 Mar 2013 12:16:16 -0400 Subject: [PATCH] Fix for minecart naming --- .../sk89q/worldedit/bukkit/BukkitWorld.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index becbb2f8c..2278ce427 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -65,7 +65,6 @@ import org.bukkit.entity.Item; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Minecart; -import org.bukkit.entity.MinecartTNT; import org.bukkit.entity.Painting; import org.bukkit.entity.Projectile; import org.bukkit.entity.TNTPrimed; @@ -115,6 +114,18 @@ public class BukkitWorld extends LocalWorld { private static Method nmsGetMethod; private static Method nmsSetSafeMethod; + // copied from WG + private static > T tryEnum(Class enumType, String ... values) { + for (String val : values) { + try { + return Enum.valueOf(enumType, val); + } catch (IllegalArgumentException e) {} + } + return null; + } + private static org.bukkit.entity.EntityType tntMinecartType; + private static boolean checkMinecartType = true; + /** * Construct the object. * @param world @@ -122,6 +133,10 @@ public class BukkitWorld extends LocalWorld { public BukkitWorld(World world) { this.world = world; + if (checkMinecartType) { + tntMinecartType = tryEnum(org.bukkit.entity.EntityType.class, "MINECART_TNT"); + checkMinecartType = false; + } // check if we have a class we can use for nms access // only run once per server startup @@ -1032,7 +1047,7 @@ public class BukkitWorld extends LocalWorld { ++num; } } else if (type == EntityType.TNT) { - if (ent instanceof TNTPrimed || ent instanceof MinecartTNT) { + if (ent instanceof TNTPrimed || ent.getType() == tntMinecartType) { ent.remove(); ++num; }