package de.fanta.challenge.utils;
import de.iani.cubesideutils.bukkit.items.ItemBuilder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
public class ItemUtils {
public static final ItemStack EMPTY_ICON = createGuiItem(Material.GRAY_STAINED_GLASS_PANE, Component.empty(), true, false);
public static ItemStack createGuiItem(Material material, Component name, Component... lore) {
return createGuiItem(material, name, false, lore);
}
public static ItemStack createGuiItem(Material material, Component name, boolean glowing, boolean showTooltip, Component... lore) {
if (!name.style().hasDecoration(TextDecoration.ITALIC)) {
name = name.decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE);
}
for (int i = 0; i < lore.length; i++) {
Component component = lore[i];
if (!component.style().hasDecoration(TextDecoration.ITALIC)) {
component = component.decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE);
}
lore[i] = component;
}
ItemBuilder builder = ItemBuilder.fromMaterial(material).displayName(name).lore(lore);
if (glowing) {
builder.enchantment(Enchantment.UNBREAKING, 1, true).flag(ItemFlag.HIDE_ENCHANTS);
}
if (!showTooltip) {
builder.hideTooltip(true);
}
return builder.build();
}
public static ItemStack createGuiItem(Material material, Component name, boolean glowing, Component... lore) {
return createGuiItem(material, name, glowing, true, lore);
}
}