Showing item using HoveEvent

Discussion in 'Spigot Plugin Development' started by gronnmann, Jun 22, 2016.

  1. So, I am developing a plugin, but need help with one thing. I want to draw an item in chat, with all the lores and enchantments. What I have came to is:
    Code (Java):
    HoverEvent drawInfo = new HoverEvent(Action.SHOW_ITEM,);
    , but I don't know what to set as the BaseComponent[]. Any ideas?
  2. check this out ;)
  3. an array of component's .. example like this

    Code (Text):

    new TextComponent("Hello world");
  4. But how am I supposed to show everything from the item then?
  5. try this

    Code (Text):

     net.minecraft.server.v1_8_R1.ItemStack nms = CraftItemStack.asNMSCopy(stack);
     NBTTagCompound tag = new NBTTagCompound();;

    TextComponent message =newTextComponent("Item Information");
    message.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_ITEM, new ChatComponentText(tag.toString()).create()));
    player.sendMessage( message );

    • Useful Useful x 1
  6. Thanks, I will try this tomorror, as it's very late in Norway right now.
  7. ok no problem :)