Solved Chat Item Showcase

Discussion in 'Spigot Plugin Development' started by Richard37, Feb 2, 2020.

  1. Hi,
    does anyone know how to create that if someone with permission exclusiveemotes.item will type in chat :item: it will replace the text by an item the user holds in his hand and if someone hover over it will show the description of the item? Like it is shown in the picture.[​IMG]
  2. SteelPhoenix


    Use chat components and HoverAction.SHOW_ITEM to show items in chat.

    Listen to chat events, check if the message contains :item: and the player has sufficient permissions, then cancel the event and broadcast the chat components
  3. Thank you
    but I still do not understand how can I replace :item: by item that user holds in his hand.
  4. String.replace if you are up to java 8 or StringUtils.replace from Apache’s API (Java’s one is slower)
  5. I have this:
    Code (Java):
    public class ItemReplacement implements Listener {
        public void onItemSend(AsyncPlayerChatEvent e){
            String newMessage = e.getMessage().replace(":item:" , );
  6. I dont know what to replace after the ":item:"
    #6 Richard37, Feb 2, 2020
    Last edited: Feb 2, 2020
  7. You have to build a new message using ComponentBuilder look at the doc from md5
  8. Could you help cause I dont understand it xD