Class ItemUtils

java.lang.Object
xyz.xenondevs.invui.util.ItemUtils

public class ItemUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable org.bukkit.inventory.ItemStack @NotNull []
    clone(@Nullable org.bukkit.inventory.ItemStack @NotNull [] array)
    Creates a new array with clones of the given ItemStacks.
    static boolean
    isEmpty(@Nullable org.bukkit.inventory.ItemStack itemStack)
    Checks whether the given ItemStack is empty.
    static @Nullable org.bukkit.inventory.ItemStack
    takeUnlessEmpty(@Nullable org.bukkit.inventory.ItemStack itemStack)
    Checks whether the given ItemStack is empty and returns null if it is.

    Methods inherited from class java.lang.Object

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

    • ItemUtils

      public ItemUtils()
  • Method Details

    • isEmpty

      public static boolean isEmpty(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack)
      Checks whether the given ItemStack is empty.

      An ItemStack is considered empty if it is null, air, or has an amount of or less than 0.

      Parameters:
      itemStack - The ItemStack to check.
      Returns:
      Whether the ItemStack is empty.
    • takeUnlessEmpty

      @Nullable public static @Nullable org.bukkit.inventory.ItemStack takeUnlessEmpty(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack)
      Checks whether the given ItemStack is empty and returns null if it is.
      Parameters:
      itemStack - The ItemStack to check.
      Returns:
      The ItemStack if it is not empty or null otherwise.
    • clone

      @Nullable public static @Nullable org.bukkit.inventory.ItemStack @NotNull [] clone(@Nullable @Nullable org.bukkit.inventory.ItemStack @NotNull [] array)
      Creates a new array with clones of the given ItemStacks.
      Parameters:
      array - The array to clone.
      Returns:
      The cloned array.