Execute a method when somebody is clicking on the chat

Discussion in 'BungeeCord Plugin Development' started by simonsator, May 27, 2015.

  1. Hi guys,
    I am programming a plugin for BungeeCord and i want that a method is execute if someone is clicking on the Chat. I allready searched on the internet, but i only fined, how i would do it in Bukkit. So my question is how can i do it on BungeeCord.
    Yours faithfully, Simonsator
    #1 simonsator, May 27, 2015
    Last edited: May 27, 2015
  2. Teg


    A dirty way to do it is you could make it execute a command that calls your method.
  3. Inkzzz

    Resource Staff

    Json messages
    • Like Like x 1
    • Like Like x 1
    • Like Like x 1
  4. For all who don´t want to read the hole github project:
    Code (Text):
    String whatShouldBeWrittenIntoTheChat = "Something";
    String command = "/something";
    String hoverMessage="Click here to do something";
    jsoncode = "{'text':'" + whatShouldBeWrittenIntoTheChat + "', 'clickEvent':{'action':'run_command','value':'" + command
               + "'},'hoverEvent':{'action':'show_text','value':'"+hoverMessage+"'}}";
    player.unsafe().sendPacket(new Chat(jsoncode));
    Of course you don´t need to make it with defining firstly all variables you can directly write it into player.unsafe().sendPacket(new Chat())
  5. This is in the bungee section, why not use the bungee chat API rather than adding an extra dependency?