diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/RemoveCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/RemoveCommand.java index a88cd17bef..a0eef35f72 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/RemoveCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/RemoveCommand.java @@ -84,24 +84,33 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept dB.report(getName(), aH.debugObj("entities", entities.toString()) + (region != null ? aH.debugObj("region", region) : "")); + boolean conditionsMet; + // Go through all of our entities and remove them for (dEntity entity : entities) { + + conditionsMet = true; // If this is a specific spawned entity, and all // other applicable conditions are met, remove it - if (entity.isGeneric() == false - && region == null ? true : - WorldGuardUtilities.inRegion - (entity.getBukkitEntity().getLocation(), - region.asString())) { + if (entity.isGeneric() == false) { - if (entity.isNPC()) { - entity.getNPC().destroy(); + if (region != null) { + conditionsMet = WorldGuardUtilities.inRegion + (entity.getBukkitEntity().getLocation(), + region.asString()); } - else { - entity.remove(); + + if (conditionsMet == true) { + + if (entity.isNPC()) { + entity.getNPC().destroy(); + } + else { + entity.remove(); + } } } @@ -120,13 +129,17 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept // as our current dEntity, and all other applicable // conditions are met, remove it - if (entity.getEntityType().equals(worldEntity.getType()) - && region == null ? true : - WorldGuardUtilities.inRegion - (entity.getBukkitEntity().getLocation(), - region.asString())) { + if (entity.getEntityType().equals(worldEntity.getType())) { + + if (region != null) { + conditionsMet = WorldGuardUtilities.inRegion + (worldEntity.getLocation(), + region.asString()); + } - worldEntity.remove(); + if (conditionsMet == true) { + worldEntity.remove(); + } } } }