Search in sources :

Example 26 with BaseComponent

use of net.md_5.bungee.api.chat.BaseComponent in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method getLore.

@Override
public List<String> getLore(ItemTag item) {
    if (!item.getItemMeta().hasLore()) {
        return null;
    }
    net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item.getItemStack());
    ListTag list = ((net.minecraft.nbt.CompoundTag) nmsItemStack.getTag().get("display")).getList("Lore", 8);
    List<String> outList = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
        BaseComponent[] lineComponent = ComponentSerializer.parse(list.getString(i));
        outList.add(FormattedTextHelper.stringify(lineComponent, ChatColor.WHITE));
    }
    return outList;
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ListTag(net.minecraft.nbt.ListTag)

Aggregations

BaseComponent (net.md_5.bungee.api.chat.BaseComponent)23 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)7 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)6 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)5 Player (org.bukkit.entity.Player)4 BookMeta (org.bukkit.inventory.meta.BookMeta)4 UPlayer (xyz.derkades.ublisk.utils.UPlayer)4 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)3 ListTag (com.denizenscript.denizencore.objects.core.ListTag)3 ChatColor (net.md_5.bungee.api.ChatColor)3 MapTag (com.denizenscript.denizencore.objects.core.MapTag)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ListTag (net.minecraft.nbt.ListTag)2 EventHandler (org.bukkit.event.EventHandler)2 PlayerNotFoundException (xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)2 MinigamesBroadcastEvent (au.com.mineauz.minigames.events.MinigamesBroadcastEvent)1 EntityTag (com.denizenscript.denizen.objects.EntityTag)1 ItemTag (com.denizenscript.denizen.objects.ItemTag)1