Solved How to create a ClickEvent on TextComponent?

Cyanoure

New member
Jul 17, 2022
2
0
1
I also searched on google but it only shows that is not related to this Velocity.
I'm not an expert, this is my first Velocity plugin. (I have some experience in Spigot and Bungee plugin dev.)
I don't know how to send a text message to a player with a clickable link.
This is my code:
Java:
TextComponent msgc = Component.text("click here");
msgc.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://example.com/"));
player.sendMessage(msgc);
But this is not working. My IDE (IntelliJ) says this at "new ClickEvent":
'ClickEvent(net.kyori.adventure.text.event.ClickEvent.@org.jetbrains.annotations.NotNull Action, [email protected] String)' has private access in 'net.kyori.adventure.text.event.ClickEvent'
1658015072437.png
I have no idea what to do.
 
Version Output
3.1.1
Last edited:

Vicarious

New member
Jan 4, 2022
2
0
1
Components are immutable, methods will return a new component.

Don't use the clickevent constructor, use it's static methods instead.
 

Cyanoure

New member
Jul 17, 2022
2
0
1
Components are immutable, methods will return a new component.

Don't use the clickevent constructor, use it's static methods instead.
Thank you, you're my hero!
Java:
msgc = msgc.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL,url));
player.sendMessage(msgc);
I'm used to spigot. 😅