From 32341393fe8f2940ca72348b1939dd661ca24e33 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 27 Sep 2015 20:38:56 -0400 Subject: [PATCH] Armor stands no longer get removed by /stoplag. Also restored MC1.7 compatibility to pistons. --- .../java/com/sk89q/worldguard/bukkit/BukkitUtil.java | 9 ++++++++- .../bukkit/listener/EventAbstractionListener.java | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java b/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java index e1982284..3bbf5f16 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java @@ -29,6 +29,7 @@ import com.sk89q.worldguard.blacklist.target.Target; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import com.sk89q.worldguard.util.Enums; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.*; @@ -276,6 +277,9 @@ public static String replaceColorMacros(String str) { return str; } + private static final org.bukkit.entity.EntityType armorStandType = + Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND"); + /** * Returns whether an entity should be removed for the halt activity mode. * @@ -289,7 +293,8 @@ public static boolean isIntensiveEntity(Entity entity) { || entity instanceof FallingBlock || (entity instanceof LivingEntity && !(entity instanceof Tameable) - && !(entity instanceof Player)); + && !(entity instanceof Player) + && !(entity.getType() == armorStandType)); } /** @@ -299,7 +304,9 @@ public static boolean isIntensiveEntity(Entity entity) { * @param enumType enum class * @param values values to test * @return a value in the enum or null + * @deprecated use {@link Enums#findByValue(Class, String...)} */ + @Deprecated public static > T tryEnum(Class enumType, String ... values) { for (String val : values) { try { diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 1b05a1de..dec4439d 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -253,7 +253,15 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) { BlockFace direction = event.getDirection(); - ArrayList blocks = new ArrayList(event.getBlocks()); + ArrayList blocks; + try { + blocks = new ArrayList(event.getBlocks()); + } catch (NoSuchMethodError e) { + blocks = Lists.newArrayList(event.getRetractLocation().getBlock()); + if (piston.getType() == Material.PISTON_MOVING_PIECE) { + direction = new PistonExtensionMaterial(Material.PISTON_STICKY_BASE.getId(), piston.getData()).getFacing(); + } + } int originalSize = blocks.size(); Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, cause, event.getBlock().getWorld(), blocks, Material.AIR)); if (originalSize != blocks.size()) {