Sending a message to all the OP players

Discussion in 'Plugin Development' started by EtgarSH, Sep 17, 2013.

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

    EtgarSH

    I get the online players, and than wanna check each of the online players if he is OP and than send all the OPs a message. How can I do it? THX [=
     
  2. Offline

    L33m4n123

    Code:java
    1. for (Player player: Bukkit.getOnlinePlayers()) {
    2. if(player.isOP()) player.sendMessage("Your message");
    3. }
     
    EtgarSH likes this.
  3. Offline

    EdenCampo

    EtgarSH
    Code:java
    1. for(Player player : Bukkit.getServer().getOnlinePlayers())
    2. {
    3. if(player.isOp())
    4. {
    5. player.sendMessage("Your message");
    6. }
    7. }
     
    EtgarSH likes this.
  4. Offline

    L33m4n123

    EdenCampo oh you need the .getServer() aswell? good to know
    EtgarSH ignore my code then^^
     
    EtgarSH likes this.
  5. Offline

    chasechocolate

    L33m4n123 no, the .getServer() is optional.
     
    Janmm14, L33m4n123 and EtgarSH like this.
  6. Offline

    EtgarSH

    THX a lot!!!
     
Thread Status:
Not open for further replies.

Share This Page