Package net.tnemc.item.bukkit
Class BukkitCalculationsProvider
java.lang.Object
net.tnemc.item.bukkit.BukkitCalculationsProvider
- All Implemented Interfaces:
CalculationsProvider<BukkitItemStack,
org.bukkit.inventory.ItemStack, org.bukkit.inventory.Inventory>
public class BukkitCalculationsProvider
extends Object
implements CalculationsProvider<BukkitItemStack,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 TypeMethodDescriptionint
count
(BukkitItemStack stack, org.bukkit.inventory.Inventory inventory) Returns a count of items equal to the specific stack in an inventory.boolean
drop
(Collection<BukkitItemStack> left, UUID player, boolean setOwner) Removes items from a collection based on certain criteria.giveItems
(Collection<BukkitItemStack> 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.int
removeAll
(BukkitItemStack stack, org.bukkit.inventory.Inventory inventory) Removes all items that are equal to the stack from an inventory.int
removeItem
(BukkitItemStack stack, org.bukkit.inventory.Inventory inventory) Removes an ItemStack with a specific amount from an inventory.void
takeItems
(Collection<BukkitItemStack> 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, wait
Methods inherited from interface net.tnemc.item.providers.CalculationsProvider
count, giveItems, itemsEqual, itemsEqual, removeAll, removeItem, takeItems
-
Constructor Details
-
BukkitCalculationsProvider
public BukkitCalculationsProvider()
-
-
Method Details
-
drop
Removes items from a collection based on certain criteria.- Specified by:
drop
in interfaceCalculationsProvider<BukkitItemStack,
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:
removeAll
in interfaceCalculationsProvider<BukkitItemStack,
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:
count
in interfaceCalculationsProvider<BukkitItemStack,
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:
takeItems
in interfaceCalculationsProvider<BukkitItemStack,
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<BukkitItemStack> giveItems(Collection<BukkitItemStack> 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:
giveItems
in interfaceCalculationsProvider<BukkitItemStack,
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:
removeItem
in interfaceCalculationsProvider<BukkitItemStack,
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:
inventory
in interfaceCalculationsProvider<BukkitItemStack,
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.
-