Need Help with Click Events in Chat

Discussion in 'Plugin Development' started by MrGamingLion66, Sep 10, 2016.

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

    MrGamingLion66

    Hello everyone, as part of a lobby join plugin that i'm working on I need to use click events on certain chat messages.

    Code:
    e.getPlayer().sendMessage("§b==================================================");
                e.getPlayer().sendMessage("§6§lWelcome " + p.getName() + " to " + "§c§lCRIMSON CENTRAL");
                e.getPlayer().sendMessage("");
                e.getPlayer().sendMessage("§e§lOur Website:" + " §b§lhttp://crimsoncentral.weebly.com");
                e.getPlayer().sendMessage("");
                e.getPlayer().sendMessage("§2§l9 Open Mini-Games! " + "§2§l(Click Here for More Details)");
                e.getPlayer().sendMessage("");
                e.getPlayer().sendMessage("§e§lRules " + "§d§l(Click to View)");
                e.getPlayer().sendMessage("§b==================================================");
    The Idea is that when you click on the Click for more detail or click to veiw it will send a couple more chat messages. Can anyone help.
     
  2. Offline

    oceantheskatr

    Look in to JSON chat messages :)
     
  3. Offline

    JanTuck

  4. Offline

    ArsenArsen

    @JanTuck not a good idea to use commands, you need a new custom sender and you need to know syntax stays the same. Use JSON messages.
     
  5. @MrGamingLion66 dood, I have the perfect Library for you xD. I literally use this in every one of my plugins, and answering the question now. No. It doesn't require any external plugins. The Library is called Fanciful,can't it's fir making JSON chat messages with hover, and click events.
     
  6. Offline

    MrGamingLion66

    Hello everyone. I finnaly manged to fix some issue and find a tutorial for the clickable chat text. This is what I have now:
    Code:
    @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
    
                    sendMessage(p);
        }
    
    public void sendMessage(Player p)
        {
            BaseComponent message = new BaseComponent( "Click me" );
            message.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, "http://spigotmc.org" ) );
            p.spigot().sendMessage( message );
        }
    However I am still getting this error:
    Cannot instantiate the type BaseComponent

    Can anyone help me fix this issue?
     
    Last edited: Sep 13, 2016
Thread Status:
Not open for further replies.

Share This Page