[SOLVED] Message Click Event error :(

Discussion in 'Spigot Plugin Development' started by dunklesToast, Apr 30, 2015.

  1. Code (Text):
                for(Player pp : Bukkit.getOnlinePlayers()) {
                    TitleManager.sendTitles(pp,"§cANGRIFF!",p.getName() + " greift jetzt an!", 20, 3*20, 20);
                    TextComponent message = new TextComponent( " Klicke §f[§aHier§f]" );
                    message.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "tp"+ p.getCustomName() ) );
                    message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schau zu!").create() ) );
                    Bukkit.broadcastMessage(message);
                    pp.sendMessage(Main.prefix + " Du willst zuschauen?");
                       
                }
    So, I copied it from the spigot website but Eclipse says:

    The method broadcastMessage(String) in the type Bukkit is not applicable for the arguments (TextComponent).

    But if I want to change it into a String there are another errors. How can I fix it?
    Spigot 1.8.3
     
  2. 1. Loop through all online players
    2. Send the message to the players
     
  3. gigosaurus

    Supporter

    TextComponent is part of the Bungee API and not the Bukkit API, and so Bukkit.broadcastMessage(TextComponent) does not exist, however player.spigot().sendMessage(BaseComponent) does.
     
    #3 gigosaurus, Apr 30, 2015
    Last edited: Apr 30, 2015
  4. So:
    Code (Text):

    for(Player pp : Bukkit.getOnlinePlayers()) {
                    TitleManager.sendTitles(pp,"§cANGRIFF!",p.getName() + " greift jetzt an!", 20, 3*20, 20);
                    TextComponent message = new TextComponent( " Klicke §f[§aHier§f]" );
                    message.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "tp"+ p.getCustomName() ) );
                    message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schau zu!").create() ) );
                    pp.sendMessage(message);
                    pp.sendMessage(Main.prefix + " Du willst zuschauen?");
                       
                }
     
    Same error :(((
     
  5. pp.spigot().sendMessage()
     
    • Like Like x 1
  6. THANK YOU! WORKS!
     
  7. Feel free to leave a like when i helped you ;)
     
  8. Done :)
     
  9. :D
    If you need further help you can send me a pm ;)