Search in sources :

Example 1 with ItemStackClearEvent

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();
}
Also used : Item(org.bukkit.entity.Item) ArrayList(java.util.ArrayList) ItemStackClearEvent(dev.rosewood.rosestacker.event.ItemStackClearEvent)

Aggregations

ItemStackClearEvent (dev.rosewood.rosestacker.event.ItemStackClearEvent)1 ArrayList (java.util.ArrayList)1 Item (org.bukkit.entity.Item)1