Broadcast A Message for Player with Permission.

Discussion in 'Plugin Development' started by JeykoExample, Jul 26, 2014.

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

    JeykoExample

    Hello Guys, i wanted to ask you, how i can send Player a Message that have a specified Permission, but only to the Players that have the Permissions, the other guys not ....

    from all online Players...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    myminecrafter01

    Get all the player online using Bukkit.getOnlinePlayers(), then loop through the players and check if they have permission, if they do send them a message.
     
  3. Offline

    bobacadodl

    You can just do Bukkit.broadcast(String message, String permission);
     
    Code0 likes this.
  4. Offline

    JeykoExample

    myminecrafter01 How can i do that, i'm a newbie ... and i want to ask if the players (all online players) is in a specified world...
     
  5. Offline

    myminecrafter01

    JeykoExample
    Many permissions plugins allow per world permissions so you could just check the permission, and set the per world part in the permission plugin. In which case you could use Bukkit.broadcast(String message, String permission) as bobacadodl pointed out, I wasn't aware that method existed. If you wanted to check the world you could so something like this:
    Code:java
    1. for (Player player : Bukkit.getOnlinePlayers()) {
    2. if (player.hasPermission("permission.node")) {
    3. if (player.getWorld().getName().equals("world name")) {
    4. //code
    5. }
    6. }
    7. }
     
  6. Offline

    Code0

    JeykoExample use this example.
     
Thread Status:
Not open for further replies.

Share This Page