Solved Check if online players have a permission.

Discussion in 'Plugin Development' started by DaChosenWon, Oct 27, 2014.

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

    DaChosenWon

    I want to check if any online players have a permission. If so, I want a message to be sent to them. Here is what I have so far.

    Code:
    package me.DaChosenWon.HelpMe;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class HelpMe extends JavaPlugin {
     
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
           
                if(cmd.getName().equalsIgnoreCase("helpme")) {
                    if(args.length < 1){
                        player.sendMessage(ChatColor.WHITE + "Are you sure you want to ask the owner? Do /helpme confirm.");
                    } else if(args[0].equalsIgnoreCase("confirm")) {
                        player.sendMessage("You said, " + ChatColor.RED + "yes" + ChatColor.WHITE + ", you need help!");
                        player.sendMessage("Message sent to owner.");
                        //I want to loop through all the online players, check if they have a certain permission, if so, send them a message.
                    }
                }
            }
            return false;
        }
    }
     
           
    
     
  2. Offline

    fireblast709

    DaChosenWon Use a for-each loop \o/. If you don't know what the f I am going on about, then it should be obvious that you don't know enough Java to proceed with Bukkit.
     
    Epicballzy likes this.
  3. Offline

    DaChosenWon

Thread Status:
Not open for further replies.

Share This Page