Loop Through Online Players

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 2, 2017.

  1. On a plugin I am making it is made for custom kicks and bans for my server. I want it to send a notification to all of the staff members. I don't know how to make it look through all of the online players and check if they have the permission minegrid.kicknotify so how would I do that?
     
  2. Code (Java):
    for(Player player : Bukkit.getServer().getOnlinePlayers(){
        if(player.hasPermission(/*permission*/){
            // do something
        }
    }
     
  3. You can do this with
    Code (Text):
    Bukkit.broadcast(<message>, <permission>);
    You could alternatively loop through
    Code (Text):
    Bukkit.getOnlinePlayers()
    and use
    Code (Text):
    <player>.hasPermission(<permission>);
     
  4. Oh wow that first one is super easy thanks so much :D