@@ -0,0 +1,2795 @@
+/*%0A * Copyright (c) 2013 - 2015 xxyy (Philipp Nowak; devnull@nowak-at.net). All rights reserved.%0A *%0A * Any usage, including, but not limited to, compiling, running, redistributing, printing,%0A *  copying and reverse-engineering is strictly prohibited without explicit written permission%0A *  from the original author and may result in legal steps being taken.%0A *%0A * See the included LICENSE file (core/src/main/resources) or email xxyy98+xyclicense@gmail.com for details.%0A */%0A%0Apackage io.github.xxyy.common.chat;%0A%0Aimport net.md_5.bungee.api.chat.BaseComponent;%0Aimport net.md_5.bungee.api.chat.HoverEvent.Action;%0Aimport net.md_5.bungee.chat.ComponentSerializer;%0Aimport org.bukkit.inventory.ItemStack;%0Aimport org.bukkit.inventory.meta.ItemMeta;%0A%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * Builds item data for use in %7B@link Action#SHOW_ITEM%7D type hover events in chat components.%0A *%0A * @author %3Ca href=%22http://xxyy.github.io/%22%3Exxyy%3C/a%3E%0A * @since 2015-12-27%0A */%0Apublic class ItemComponentBuilder %7B%0A    private final ItemStack stack;%0A%0A    public ItemComponentBuilder(ItemStack stack) %7B%0A        this.stack = stack;%0A    %7D%0A%0A    /**%0A     * Creates an array of base components representing this builder's item for use in hover events.%0A     *%0A     * @return an array of base components%0A     */%0A    public BaseComponent%5B%5D create() %7B%0A        StringBuilder tagBuilder = new StringBuilder(%22%7B%22);%0A        if (stack.hasItemMeta())%7B%0A            ItemMeta meta = stack.getItemMeta();%0A            boolean hasDisplayName = meta.hasDisplayName();%0A            boolean hasLore = meta.hasLore();%0A            if (hasDisplayName %7C%7C hasLore)%7B%0A                tagBuilder.append(%22display:%7B%22);%0A                if (hasDisplayName)%7B%0A                    tagBuilder.append(%22Name:%22).append(meta.getDisplayName());%0A                    if (hasLore)%7B%0A                        tagBuilder.append(%22,%22);%0A                    %7D%0A                %7D%0A                if (hasLore)%7B%0A                    tagBuilder.append(%22Lore:%22)%0A                            .append(meta.getLore().stream()%0A                                    .collect(Collectors.joining(%22%5C%5C%5C%22, %5C%5C%5C%22%22, %22%5B%5C%5C%5C%22%22, %22%5C%5C%5C%22%5D%22)));%0A                %7D%0A                tagBuilder.append(%22%7D%22);%0A            %7D%0A%0A        %7D%0A        tagBuilder.append(%22%7D%22);%0A%0A%0A        //noinspection deprecation%0A        return ComponentSerializer.parse(String.format(%22%7B%22 +%0A                        %22action:show_item,%22 +%0A                        %22value:%5C%22%7B%22 +%0A                        %22  id:minecraft:%25s,%22 +%0A                        %22  Count: %25d%22 +%0A                        %22  tag:%25s%22 +%0A                        %22  %7D%22 +%0A                        %22%7D%5C%22%22 +%0A                        %22%7D%22,%0A                stack.getType().name().toLowerCase(),%0A                stack.getAmount(),%0A                tagBuilder.toString()%0A        ));%0A    %7D%0A%7D%0A

Add ItemComponentBuilder for item info in hover events (cherry picked from commit 1436cbf)