Package net.tnemc.item.paper
Class PaperCalculationsProvider
java.lang.Object
net.tnemc.item.paper.PaperCalculationsProvider
- All Implemented Interfaces:
CalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory>
public class PaperCalculationsProvider
extends Object
implements CalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack,org.bukkit.inventory.Inventory>
Represents a Bukkit implementation of the
CalculationsProvider.- Since:
- 0.1.5.0
- Author:
- creatorfromhell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcount(PaperItemStack stack, org.bukkit.inventory.Inventory inventory) Returns a count of items equal to the specific stack in an inventory.booleandrop(Collection<PaperItemStack> left, UUID player, boolean setOwner) Removes items from a collection based on certain criteria.giveItems(Collection<PaperItemStack> items, org.bukkit.inventory.Inventory inventory) Adds a collection of net.tnemc.item stacks to an inventory, dropping them on the ground if it's a player inventory and overflow exists.Optional<org.bukkit.inventory.Inventory> inventory(UUID identifier, InventoryType type) Used to locate an inventory for a UUID identifier.intremoveAll(PaperItemStack stack, org.bukkit.inventory.Inventory inventory) Removes all items that are equal to the stack from an inventory.intremoveItem(PaperItemStack stack, org.bukkit.inventory.Inventory inventory) Removes an ItemStack with a specific amount from an inventory.voidtakeItems(Collection<PaperItemStack> items, org.bukkit.inventory.Inventory inventory) Takes a collection of items from an inventory.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.tnemc.item.providers.CalculationsProvider
count, giveItems, itemsEqual, itemsEqual, removeAll, removeItem, takeItems
-
Constructor Details
-
PaperCalculationsProvider
public PaperCalculationsProvider()
-
-
Method Details
-
drop
Removes items from a collection based on certain criteria.- Specified by:
dropin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
left- The collection of items from which to remove items.player- The UUID of the player associated with the removal operation.setOwner- Indicates whether to set the owner of the removed items.(supports spigot/paper 1.16.5+)- Returns:
- True if the removal operation was successful, false otherwise.
-
removeAll
Removes all items that are equal to the stack from an inventory.- Specified by:
removeAllin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
stack- The stack to compare to for removal from the inventory.inventory- The inventory to remove the items from.- Returns:
- The amount of items removed.
-
count
Returns a count of items equal to the specific stack in an inventory.- Specified by:
countin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
stack- The stack to get a count of.inventory- The inventory to check.- Returns:
- The total count of items in the inventory.
-
takeItems
Takes a collection of items from an inventory.- Specified by:
takeItemsin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
items- The collection of items to remove.inventory- The inventory to remove the items from.
-
giveItems
public Collection<PaperItemStack> giveItems(Collection<PaperItemStack> items, org.bukkit.inventory.Inventory inventory) Adds a collection of net.tnemc.item stacks to an inventory, dropping them on the ground if it's a player inventory and overflow exists.- Specified by:
giveItemsin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
items- The collection of items to add to the inventory.inventory- The inventory to add the collection of items to.- Returns:
- The collection of items that won't fit in the inventory.
-
removeItem
Removes an ItemStack with a specific amount from an inventory.- Specified by:
removeItemin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
stack- The stack, with the correct amount, to remove.inventory- The inventory to return the net.tnemc.item stack from.- Returns:
- The remaining amount of items to remove.
-
inventory
Used to locate an inventory for a UUID identifier.- Specified by:
inventoryin interfaceCalculationsProvider<PaperItemStack,org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory> - Parameters:
identifier- The identifier to use for the search.type- The inventory type to return.- Returns:
- An optional containing the inventory if it works, otherwise false.
-