Package me.deecaad.core.utils
Class AdventureUtil
java.lang.Object
me.deecaad.core.utils.AdventureUtil
Utility class for working with Adventure components on items.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable List<net.kyori.adventure.text.Component> getLore(@NotNull org.bukkit.inventory.ItemStack item) static @Nullable List<net.kyori.adventure.text.Component> getLore(@NotNull org.bukkit.inventory.meta.ItemMeta meta) static @NotNull net.kyori.adventure.text.ComponentgetName(@NotNull org.bukkit.inventory.ItemStack item) Returns the display name of the item in adventure format.static voidsetLore(@NotNull org.bukkit.inventory.ItemStack item, @NotNull List<net.kyori.adventure.text.Component> lines) Sets the lore of the item.static voidsetLore(@NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull List<net.kyori.adventure.text.Component> lines) Sets the lore of the item.static voidsetLoreUnparsed(@NotNull org.bukkit.inventory.ItemStack item, @NotNull List<?> unparsedText) Sets the lore of the item.static voidsetLoreUnparsed(@NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull List<?> unparsedText) Sets the lore of the item meta.static voidsetName(@NotNull org.bukkit.inventory.ItemStack item, @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item.static voidsetName(@NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item's meta.static voidsetNameUnparsed(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String name) Sets the display name of the item.static voidsetNameUnparsed(@NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull String name) Sets the display name of the item's meta.static voidupdatePlaceholders(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack itemStack) Replaces any PlaceholderAPI placeholders present in the display name and lore of the item.
-
Method Details
-
getName
@NotNull public static @NotNull net.kyori.adventure.text.Component getName(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Returns the display name of the item in adventure format.- Parameters:
item- The item get the name from.- Returns:
- The name component.
-
setNameUnparsed
public static void setNameUnparsed(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String name) Sets the display name of the item. Parsed using MiniMessage.- Parameters:
item- The item to set the name.name- The value of the name.
-
setNameUnparsed
public static void setNameUnparsed(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull @NotNull String name) Sets the display name of the item's meta. Parsed using MiniMessage.- Parameters:
meta- The meta to set the name.name- The value of the name.
-
setName
public static void setName(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item.- Parameters:
item- The item to set the name.name- The value of the name.
-
setName
public static void setName(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item's meta.- Parameters:
meta- The meta to set the name.name- The value of the name.
-
getLore
@Nullable public static @Nullable List<net.kyori.adventure.text.Component> getLore(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
getLore
@Nullable public static @Nullable List<net.kyori.adventure.text.Component> getLore(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta) -
setLoreUnparsed
public static void setLoreUnparsed(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull List<?> unparsedText) Sets the lore of the item.The list should be a list of strings (or any list where
Object.toString()is acceptable). The strings are then parsed using MiniMessage, then set as the lore. This is quite slow, so consider parsing the list with MiniMessage first then setting it usingsetLore(ItemStack, List).- Parameters:
item- The item to set the lore.unparsedText- The list of strings.
-
setLoreUnparsed
public static void setLoreUnparsed(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull @NotNull List<?> unparsedText) Sets the lore of the item meta.The list should be a list of strings (or any list where
Object.toString()is acceptable). The strings are then parsed using MiniMessage, then set as the lore. This is quite slow, so consider parsing the list with MiniMessage first then setting it usingsetLore(ItemStack, List).- Parameters:
meta- The item meta to set the lore.unparsedText- The list of strings.
-
setLore
public static void setLore(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull List<net.kyori.adventure.text.Component> lines) Sets the lore of the item.- Parameters:
item- The item to set the lore.lines- The list of adventure components for lore.
-
setLore
public static void setLore(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta, @NotNull @NotNull List<net.kyori.adventure.text.Component> lines) Sets the lore of the item.- Parameters:
meta- The item to set the lore.lines- The list of adventure components for lore.
-
updatePlaceholders
public static void updatePlaceholders(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack itemStack) Replaces any PlaceholderAPI placeholders present in the display name and lore of the item. If PlaceholderAPI is not installed, this method is skipped.- Parameters:
player- The player holding the item.itemStack- The item to apply the placeholders to.
-