Clickable Messages

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

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

    Smeary_Subset

    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
    Code:
    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?

    Thanks,
    SmearySubset
     
  2. Offline

    Tim_M

    Try googling before posting...
     
  3. Offline

    Smeary_Subset

    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

    Kars

    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

    Smeary_Subset

    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

    Tim_M

    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:
    https://wiki.vg/Chat
    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

    Shqep

    @Tim_M
    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.

    /shrug
     
  9. Offline

    Tim_M

    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

    Kars

    You are right.
    https://stackoverflow.com/a/67497838/10832136
     
Thread Status:
Not open for further replies.

Share This Page