use of dev.rosewood.rosestacker.event.EntityStackClearEvent in project RoseStacker by Rosewood-Development.
the class StackingThread method removeAllEntityStacks.
@Override
public int removeAllEntityStacks() {
List<StackedEntity> toRemove = this.stackedEntities.values().stream().filter(x -> x.getEntity() != null && x.getEntity().getType() != EntityType.PLAYER).filter(x -> x.getStackSize() != 1 || Setting.MISC_CLEARALL_REMOVE_SINGLE.getBoolean()).collect(Collectors.toList());
EntityStackClearEvent entityStackClearEvent = new EntityStackClearEvent(this.targetWorld, toRemove);
Bukkit.getPluginManager().callEvent(entityStackClearEvent);
if (entityStackClearEvent.isCancelled())
return 0;
toRemove.stream().map(StackedEntity::getEntity).forEach(this::setRemoved);
toRemove.stream().map(StackedEntity::getEntity).forEach(LivingEntity::remove);
this.stackedEntities.values().removeIf(toRemove::contains);
return toRemove.size();
}
Aggregations