Class InventoryUtils

java.lang.Object
dev.piglin.piglinworldapi.util.InventoryUtils

public class InventoryUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    addEverythingOrNothing​(@NotNull org.bukkit.inventory.Inventory inventory, @Nullable org.bukkit.inventory.ItemStack item)
    Adds the item to the inventory, but don't add it if it can't be added fully (e.g.
    static boolean
    checkSpaceForItem​(@NotNull org.bukkit.inventory.Inventory inventory, @Nullable org.bukkit.inventory.ItemStack item)
    Checks if you can safely add the item to the specified inventory
    static List<Integer>
    getSimilarSlots​(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack item)
    Get slots in the inventory with items similar to the specified item

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InventoryUtils

      public InventoryUtils()
  • Method Details

    • checkSpaceForItem

      public static boolean checkSpaceForItem(@NotNull @NotNull org.bukkit.inventory.Inventory inventory, @Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Checks if you can safely add the item to the specified inventory
      Parameters:
      inventory - The inventory
      item - The item
      Returns:
      true if there is enough free space in the inventory, false otherwise
    • addEverythingOrNothing

      public static boolean addEverythingOrNothing(@NotNull @NotNull org.bukkit.inventory.Inventory inventory, @Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Adds the item to the inventory, but don't add it if it can't be added fully (e.g. 24 items can be added, 64 can't)
      Parameters:
      inventory - The inventory
      item - The item
      Returns:
      true if the item was added to the inventory, false otherwise
    • getSimilarSlots

      public static List<Integer> getSimilarSlots(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack item)
      Get slots in the inventory with items similar to the specified item
      Parameters:
      inventory - The inventory
      item - The item
      Returns:
      Slots with similar item