Class ItemUtil

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

public class ItemUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    editMeta(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull Consumer<@NotNull org.bukkit.inventory.meta.ItemMeta> consumer)
    A helper method for editing ItemMeta using a Consumer that takes in an ItemMeta instance.
    static void
    setItemLegacyComponentName(@NotNull org.bukkit.inventory.ItemStack itemStack, @Nullable net.kyori.adventure.text.Component newName)
    Will set the item name of the given ItemStack to the given Component name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.