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 Details

  • Method Details

    • drop

      public boolean drop(Collection<PaperItemStack> left, UUID player, boolean setOwner)
      Removes items from a collection based on certain criteria.
      Specified by:
      drop in interface CalculationsProvider<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

      public int removeAll(PaperItemStack stack, org.bukkit.inventory.Inventory inventory)
      Removes all items that are equal to the stack from an inventory.
      Specified by:
      removeAll in interface CalculationsProvider<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

      public int count(PaperItemStack stack, org.bukkit.inventory.Inventory inventory)
      Returns a count of items equal to the specific stack in an inventory.
      Specified by:
      count in interface CalculationsProvider<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

      public void takeItems(Collection<PaperItemStack> items, org.bukkit.inventory.Inventory inventory)
      Takes a collection of items from an inventory.
      Specified by:
      takeItems in interface CalculationsProvider<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:
      giveItems in interface CalculationsProvider<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

      public int removeItem(PaperItemStack stack, org.bukkit.inventory.Inventory inventory)
      Removes an ItemStack with a specific amount from an inventory.
      Specified by:
      removeItem in interface CalculationsProvider<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

      public Optional<org.bukkit.inventory.Inventory> inventory(UUID identifier, InventoryType type)
      Used to locate an inventory for a UUID identifier.
      Specified by:
      inventory in interface CalculationsProvider<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.