Class ItemUtil
java.lang.Object
net.mathias2246.buildmc.api.item.ItemUtil
A helper-class for items.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voideditMeta(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull Consumer<@NotNull org.bukkit.inventory.meta.ItemMeta> consumer) static @Nullable AbstractCustomItemgetCustomItemFromItemStack(@NotNull org.bukkit.inventory.ItemStack itemStack) Will try to get aAbstractCustomItemfrom anItemStackif it is a custom item.static voidsetName(@NotNull org.bukkit.inventory.ItemStack itemStack, @Nullable net.kyori.adventure.text.Component name) Sets the name of anItemStackto the givenComponent.
-
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 editingItemMetausing aConsumerthat takes in anItemMetainstance.The edited
ItemMetainstance will be automatically be set on theItemStackinstance after editing.If the meta returned by
itemStack.getItemMeta();equals null, nothing will happen.- Parameters:
itemStack- TheItemStackthat should be editedconsumer- The consumer used to edit theItemMeta
-
getCustomItemFromItemStack
@Nullable public static @Nullable AbstractCustomItem getCustomItemFromItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Will try to get aAbstractCustomItemfrom anItemStackif it is a custom item.- Returns:
- The
AbstractCustomItem, ornullif not a custom item.
-
setName
public static void setName(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @Nullable @Nullable net.kyori.adventure.text.Component name) Sets the name of anItemStackto the givenComponent.
-