Class ItemUtils

java.lang.Object
ch.njol.skript.bukkitutil.ItemUtils

public class ItemUtils extends Object
Miscellaneous static utility methods related to items.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable org.bukkit.Material
    asBlock(org.bukkit.Material type)
    Gets a block material corresponding to given item material, which might be the given material.
    static org.bukkit.Material
    asItem(org.bukkit.Material type)
    Gets an item material corresponding to given block material, which might be the given material.
    static int
    getDamage(org.bukkit.inventory.ItemStack stack)
    Gets damage/durability of an item, or 0 if it does not have damage.
    static boolean
    isAir(org.bukkit.Material type)
     
    static boolean
    itemStacksEqual(@Nullable org.bukkit.inventory.ItemStack is1, @Nullable org.bukkit.inventory.ItemStack is2)
    Tests whether two item stacks are of the same type, i.e.
    static void
    setDamage(org.bukkit.inventory.ItemStack stack, int damage)
    Sets damage/durability of an item if possible.

    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

    • getDamage

      public static int getDamage(org.bukkit.inventory.ItemStack stack)
      Gets damage/durability of an item, or 0 if it does not have damage.
      Parameters:
      stack - Item.
      Returns:
      Damage.
    • setDamage

      public static void setDamage(org.bukkit.inventory.ItemStack stack, int damage)
      Sets damage/durability of an item if possible.
      Parameters:
      stack - Item to modify.
      damage - New damage. Note that on some Minecraft versions, this might be truncated to short.
    • asBlock

      public static @Nullable org.bukkit.Material asBlock(org.bukkit.Material type)
      Gets a block material corresponding to given item material, which might be the given material. If no block material is found, null is returned.
      Parameters:
      type - Material.
      Returns:
      Block version of material or null.
    • asItem

      public static org.bukkit.Material asItem(org.bukkit.Material type)
      Gets an item material corresponding to given block material, which might be the given material.
      Parameters:
      type - Material.
      Returns:
      Item version of material or null.
    • itemStacksEqual

      public static boolean itemStacksEqual(@Nullable org.bukkit.inventory.ItemStack is1, @Nullable org.bukkit.inventory.ItemStack is2)
      Tests whether two item stacks are of the same type, i.e. it ignores the amounts.
      Parameters:
      is1 -
      is2 -
      Returns:
      Whether the item stacks are of the same type
    • isAir

      public static boolean isAir(org.bukkit.Material type)