Clickable Messages

Discussion in 'Plugin Development' started by Smeary_Subset, Oct 19, 2022.

Thread Status:
Not open for further replies.
  1. Offline


    I've looked around about how to do hoverable/clickable messages and I've run into TextComponents and the Chat Component API. I see a lot of old code written like
    TextComponent ts = new TextComponent("Hello world")
    . But it appears that all of it is deprecated and now TextComponent is an interface, so it cannot be instantiated.

    What current methods of writing hoverable/clickable messages are there?

  2. Offline


    Try googling before posting...
  3. Offline


    As mentioned in my first post, I did look around but didn't find anything that worked. I tried that FancifulMessage api but it doesn't seem to support method calls on click. Instead, it seems to only support command calls and links.

    What I am trying to do is create a system where a player can share a location (in the form of a string) with someone, and then the recipient can click the notification message to view the location string.

    Any other ideas?
  4. Online

    timtower Administrator Administrator Moderator

    Have you seen this functional anywhere then?
  5. Offline


    As far as i know there are no clickable messages in the vanilla client. That's why most servers use inventories to handle user input.
  6. Offline


    Actually, that's a good point. I just went to the old 1.15 way of doing this (which I have done before) and then it was the same thing: only command calls on click. Maybe I will have to do it this way.
  7. Offline


    I mean I remember seeing it on Mineplex, in 1.8.9, so there definetaly has to be a way, I'm guessing sending and listnening for packets could work.

    Also @Smeary_Subset, I recommed you check this out:
    Specifically "clickEvent"

    You will need to send the JSON text via packets or Spigots methods such as Player.sendMessage(JSONText); will not work.
    You can also use TextComponents (BungeeCord).
  8. Offline


    Yea there's a weird wacky way to do it.
    Just use the fact that the message can execute a command as you. Let's say like /dothisthing <uuid>
    And then you look up that uuid in a Map<UUID, Function> of some sorts, then execute that function.

  9. Offline


    There are, they're called clickevents, but atleast to my knowledge are far more annoying to work with, because you have the use packets. Also they can go out of reach if there's spam in chat, so most devs just stick to inventory UIs.
  10. Offline


    You are right.
Thread Status:
Not open for further replies.

Share This Page