Interface CalculationsProvider<I extends AbstractItemStack<S>,S,U>

Type Parameters:
I - The implementation's instance of AbstractItemStack
S - The implementation's instance of item stacks.
U - The implementation's instace of inventories.
All Known Implementing Classes:
BukkitCalculationsProvider, PaperCalculationsProvider

public interface CalculationsProvider<I extends AbstractItemStack<S>,S,U>
Represents a provider that is utilized for item-based calculations and comparisons.
Since:
0.1.5.0
Author:
creatorfromhell
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    count(I stack, UUID identifier)
    Returns a count of items equal to the specific stack in an inventory.
    int
    count(I stack, U inventory)
    Returns a count of items equal to the specific stack in an inventory.
    boolean
    drop(Collection<I> left, UUID player, boolean setOwner)
    Removes items from a collection based on certain criteria.
    default Collection<I>
    giveItems(Collection<I> items, UUID identifier)
    Adds a collection of item stacks to an inventory, returns the leftover items that won't fit in the inventory.
    giveItems(Collection<I> items, U inventory)
    Adds a collection of item stacks to an inventory, returns the leftover items that won't fit in the inventory.
    inventory(UUID identifier, InventoryType type)
    Used to locate an invetory for a UUID identifier.
    default boolean
    itemsEqual(I original, I compare)
    Checks to see if two net.tnemc.item stacks are equal.
    default boolean
    itemsEqual(I original, S compare)
    Checks to see if two net.tnemc.item stacks are equal.
    default int
    removeAll(I stack, UUID identifier)
    Removes all items that are equal to the stack from an inventory.
    int
    removeAll(I stack, U inventory)
    Removes all items that are equal to the stack from an inventory.
    default int
    removeItem(I stack, UUID identifier)
    Removes an net.tnemc.item stack with a specific amount from an inventory.
    int
    removeItem(I stack, U inventory)
    Removes an net.tnemc.item stack with a specific amount from an inventory.
    default void
    takeItems(Collection<I> items, UUID identifier)
    Takes a collection of items from an inventory.
    void
    takeItems(Collection<I> items, U inventory)
    Takes a collection of items from an inventory.
  • Method Details

    • drop

      boolean drop(Collection<I> left, UUID player, boolean setOwner)
      Removes items from a collection based on certain criteria.
      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

      int removeAll(I stack, U inventory)
      Removes all items that are equal to the stack from an 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.
    • removeAll

      default int removeAll(I stack, UUID identifier)
      Removes all items that are equal to the stack from an inventory.
      Parameters:
      stack - The stack to compare to for removal from the inventory.
      identifier - The identifier of the player to remove the items from.
      Returns:
      The amount of items removed.
    • count

      int count(I stack, U inventory)
      Returns a count of items equal to the specific stack in an inventory.
      Parameters:
      stack - The stack to get a count of.
      inventory - The inventory to check.
      Returns:
      The total count of items in the inventory.
    • count

      default int count(I stack, UUID identifier)
      Returns a count of items equal to the specific stack in an inventory.
      Parameters:
      stack - The stack to get a count of.
      identifier - The identifier of the player to check.
      Returns:
      The total count of items in the inventory.
    • takeItems

      void takeItems(Collection<I> items, U inventory)
      Takes a collection of items from an inventory.
      Parameters:
      items - The collection of items to remove.
      inventory - The inventory to remove the items from.
    • takeItems

      default void takeItems(Collection<I> items, UUID identifier)
      Takes a collection of items from an inventory.
      Parameters:
      items - The collection of items to remove.
      identifier - The identifier of the player to remove the items from.
    • giveItems

      Collection<I> giveItems(Collection<I> items, U inventory)
      Adds a collection of item stacks to an inventory, returns the leftover items that won't fit in the 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.
    • giveItems

      default Collection<I> giveItems(Collection<I> items, UUID identifier)
      Adds a collection of item stacks to an inventory, returns the leftover items that won't fit in the inventory.
      Parameters:
      items - The collection of items to add to the inventory.
      identifier - The identifier of the player to add the collection of items to.
      Returns:
      The collection of items that won't fit in the inventory.
    • removeItem

      int removeItem(I stack, U inventory)
      Removes an net.tnemc.item stack with a specific amount from an inventory.
      Parameters:
      stack - The stack, with the correct amount, to remove.
      inventory - The inventory to remove the net.tnemc.item stack from.
      Returns:
      The remaining amount of items to remove.
    • removeItem

      default int removeItem(I stack, UUID identifier)
      Removes an net.tnemc.item stack with a specific amount from an inventory.
      Parameters:
      stack - The stack, with the correct amount, to remove.
      identifier - The identifier of the player to remove the net.tnemc.item stack from.
      Returns:
      The remaining amount of items to remove.
    • inventory

      Optional<U> inventory(UUID identifier, InventoryType type)
      Used to locate an invetory for a UUID identifier.
      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.
    • itemsEqual

      default boolean itemsEqual(I original, S compare)
      Checks to see if two net.tnemc.item stacks are equal.
      Parameters:
      original - The original net.tnemc.item stack.
      compare - The net.tnemc.item stack you're comparing to the original.
      Returns:
      True if the net.tnemc.item stacks are equal, otherwise false.
    • itemsEqual

      default boolean itemsEqual(I original, I compare)
      Checks to see if two net.tnemc.item stacks are equal.
      Parameters:
      original - The original net.tnemc.item stack.
      compare - The net.tnemc.item stack you're comparing to the original.
      Returns:
      True if the net.tnemc.item stacks are equal, otherwise false.