use of dev.rosewood.rosestacker.event.ItemStackClearEvent in project RoseStacker by Rosewood-Development.
the class StackingThread method removeAllItemStacks.
@Override
public int removeAllItemStacks() {
List<StackedItem> toRemove = new ArrayList<>(this.stackedItems.values());
ItemStackClearEvent itemStackClearEvent = new ItemStackClearEvent(this.targetWorld, toRemove);
Bukkit.getPluginManager().callEvent(itemStackClearEvent);
if (itemStackClearEvent.isCancelled())
return 0;
toRemove.stream().map(StackedItem::getItem).forEach(this::setRemoved);
toRemove.stream().map(StackedItem::getItem).forEach(Item::remove);
this.stackedItems.values().removeIf(toRemove::contains);
return toRemove.size();
}
Aggregations