Detect Name Click

Discussion in 'Spigot Plugin Development' started by Justin393, Dec 24, 2015.

  1. How would I go about detecting if someone clicks on a player's name in chat? I know it involves JSON, but I have never done this before and was hoping that someone would be able to explain this to me? I would like to know how to run a command on click and give a tooltip on hover.
     
  2. The thing is, you can't detect this afterwards and do some action. Rather the click and hover event has to be added into the chat when it is sent.
    Typically this would involve 'kidnapping' all chat and replacing it with your own format which has those events in it.

    See ComponentAPI, you don't have to touch any of the underlying JSON
     
  3. Seems to be exclusive to the Bungee API? Unless I'm mistaken I can't use this on a non bungee cord server?
     
  4. It used to be, but since 1.8.4 it's also included in Spigot
    You can send the chat to a player using player.spigot().sendMessage();
    And use a ComponentBuilder