@A in command

Discussion in 'Spigot Help' started by LazerShadow, May 25, 2015.

  1. Right now I am trying to make a /announce command basically like /say but it pops text on your screen as well. I need to know how to do @a in a command. Here is my code, so if there is an alternate way to do it then that would be great.

    Code (Text):
    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "title @a title {text:\"Announce\",color:\"gold\",bold:true}");
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "title @a times 15 70 15");
    Whole class
    Code (Text):
    package Commands;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    public class Announce implements CommandExecutor{
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
       
            if (cmd.getName().equalsIgnoreCase("announce")) {
           
                if(!sender.hasPermission("ct.admin")) {
                    sender.sendMessage(ChatColor.GOLD + "Permissoins> " + ChatColor.GRAY + "Only " + ChatColor.RED + "Admins+ " + ChatColor.GRAY + "can use this command.");
                    return true;
                } else {
                    String message = "";
               
                    for (int i = 0; i != args.length; i++)
                    message += args[i] + " ";
               
                    Bukkit.broadcastMessage("§l§ka " + ChatColor.GOLD + "Announcement> " + ChatColor.RED + message);
               
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "title @a title {text:\"Announce\",color:\"gold\",bold:true}");
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "title @a times 15 70 15");
               
               
                }
                if(args.length == 0) {
                    sender.sendMessage(ChatColor.GOLD + "Say> " + ChatColor.GRAY + "Improper usage. " + ChatColor.RED + "/say <message>" + ChatColor.GRAY + ".");
                    return true;
                }
               
                return true;
            }
       
            return false;
        }
    }
     
  2. Iterate through all of the online players?
     
  3. That's too magical
     
  4. Check the tutorial I made on the wiki.
     
    • Like Like x 1
  5. Link to page?