From 95bf6bc9b24366daea5e06fd9954ef7b5acd5246 Mon Sep 17 00:00:00 2001 From: wizjany Date: Mon, 6 Jul 2015 01:39:39 -0400 Subject: [PATCH] Be overly protective for creeper and enderdragon explosions. Fixes WORLDGUARD-3522. --- .../bukkit/listener/RegionFlagsListener.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionFlagsListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionFlagsListener.java index 37812bc7..bdcd88db 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionFlagsListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionFlagsListener.java @@ -32,9 +32,8 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -90,25 +89,22 @@ public void onBreakBlock(final BreakBlockEvent event) { } } - Entity entity; - if ((entity = event.getCause().getFirstNonPlayerEntity()) != null) { - // ================================================================ - // CREEPER_EXPLOSION flag - // ================================================================ - - if (entity instanceof Creeper) { // Creeper - event.filter(testState(query, DefaultFlag.CREEPER_EXPLOSION), config.explosionFlagCancellation); - } - - // ================================================================ - // ENDERDRAGON_BLOCK_DAMAGE flag - // ================================================================ - - if (entity instanceof EnderDragon) { // Enderdragon - event.filter(testState(query, DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE), config.explosionFlagCancellation); - } + // ================================================================ + // CREEPER_EXPLOSION flag + // ================================================================ + if (event.getCause().find(EntityType.CREEPER) != null) { // Creeper + event.filter(testState(query, DefaultFlag.CREEPER_EXPLOSION), config.explosionFlagCancellation); } + + // ================================================================ + // ENDERDRAGON_BLOCK_DAMAGE flag + // ================================================================ + + if (event.getCause().find(EntityType.ENDER_DRAGON) != null) { // Enderdragon + event.filter(testState(query, DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE), config.explosionFlagCancellation); + } + } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)