Solved Send message to players with permission but not sender

Discussion in 'Plugin Development' started by KarimAKL, Apr 2, 2018.

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

    KarimAKL

    Hey i wanna ask if this is how i should do it and if there is a better way:
    Code:
    for (Player p : Bukkit.getOnlinePlayers()) {
      if (p.hasPermission(“whateverpermission”)) {
        if (p != sender) {
          p.sendMessage(“whatevermessage”);
    
    I want to send a message to all with a specific permission but not the sender of the command so i ask:
    Is this how i do it or is it there a better way?
     
  2. Offline

    Zombie_Striker

    @KarimAKL
    Yes, that is how you would block the message from the player.
     
  3. Offline

    KarimAKL

  4. Offline

    CodeVyxis

    isn't using Bukkit#broadcast(msg, permission); easier? Its basically the same but its easier then it just gives everyone with the necessary permissionnode the broadcast and not the rest?
     
  5. Offline

    KarimAKL

    @CodeVyxis What i want here is to send a message to everyone with a permission BUT not the sender(even if the sender has the permission) So i don't think that would work in this case.
     
  6. Offline

    CodeVyxis

    aaah ok that explains
     
  7. Offline

    KarimAKL

Thread Status:
Not open for further replies.

Share This Page