Class ItemUtil

java.lang.Object
net.mathias2246.buildmc.api.item.ItemUtil

public class ItemUtil extends Object
  • Constructor Details

    • ItemUtil

      public ItemUtil()
  • Method Details

    • editMeta

      public static void editMeta(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull @NotNull Consumer<@NotNull org.bukkit.inventory.meta.ItemMeta> consumer)
      A helper method for editing ItemMeta using a Consumer that takes in an ItemMeta instance.

      The edited ItemMeta instance will be automatically be set on the ItemStack instance after editing.

      If the meta returned by itemStack.getItemMeta(); equals null, nothing will happen.

      Parameters:
      itemStack - The ItemStack that should be edited
      consumer - The consumer used to edit the ItemMeta
    • setItemLegacyComponentName

      public static void setItemLegacyComponentName(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @Nullable @Nullable net.kyori.adventure.text.Component newName)
      Will set the item name of the given ItemStack to the given Component name.
      Parameters:
      newName - The new name of the item. When null, the name will be removed from the item.
    • getCustomItemFromItemStack

      @Nullable public static @Nullable AbstractCustomItem getCustomItemFromItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Will try to get a AbstractCustomItem from an ItemStack if it is a custom item.
      Returns:
      The AbstractCustomItem, or null if not a custom item.