Clickable links

Discussion in 'BungeeCord Plugin Development' started by CraftBang, May 10, 2015.

  1. Hey I'm making a plugin for messaging cross servers but the links are not clickable :/

    Code (Text):

    player.sendMessage(new ComponentBuilder("Test or").color(ChatColor.WHITE).create());                                                      
    And I know I can make a clickevent, but what if a player msgs a link, how can I make that only that link is clickable?

    Thanks in advance,
  2. player.spigot().sendMessage()
    • Friendly Friendly x 1
  3. But player is a ProxiedPlayer, #spigot() does not exists..
  4. @_Cory_ but that is only this:
    Code (Text):

    TextComponent message = new TextComponent( "Click me" );
    message.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, "" ) );
    player.sendMessage( message );
    I want that if a player sends a random link that it's clickable like how the normal chat works.
    Could I implement spigot someway to make this work?
  5. You have to split the user's input into multiple parts, so that you can add the click event only to the part you want it to.
    Then add all the parts to the first one (as extra) and send it to the player.
    • Useful Useful x 1
  6. If you still have some difficulties you want to use the fanciful linnrary
    • Useful Useful x 1
  7. If you split by spaces and run an URL regex against each one, turning each URL match into a click event, then there you go.
    • Useful Useful x 1
  8. It work for me :)
  9. When a player recieves a link message, can't the player open the url without applying any links to it? Cause when you type a link in chat you can just open it.