@Override
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
// Get objects
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
dWorld world = (dWorld) scriptEntry.getObject("world");
Element region = (Element) scriptEntry.getObject("region");
// Report to dB
dB.report(scriptEntry, getName(), aH.debugList("entities", entities) +
(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()) {
if (region != null) {
dB.echoError(scriptEntry.getResidingQueue(), "Region support is deprecated!");
/*conditionsMet = WorldGuardUtilities.inRegion
(entity.getBukkitEntity().getLocation(),
region.asString());*/
}
if (conditionsMet) {
if (entity.isNPC()) {
entity.getDenizenNPC().getCitizen().destroy();
}
else {
entity.remove();
}
}
}
// If this is a generic unspawned entity, remove
// all entities of this type from the world (as
// long as they meet all other conditions)
else {
// Note: getting the entities from each loaded chunk
// in the world (like in Essentials' /killall) has the
// exact same effect as the below
for (Entity worldEntity : world.getEntities()) {
// If this entity from the world is of the same type
// as our current dEntity, and all other applicable
// conditions are met, remove it