How to make a user immune to a command if they have permission(BLAH.BLAH)?

Discussion in 'Plugin Development' started by Trevor1134, Jun 28, 2013.

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

    Trevor1134

    Basically, if ANY user on the server has a certain permission, they don't get affected. So lets say its for a global mute, how do I make it so if any user has the select permission, they don't get muted?
     
  2. Offline

    Garris0n

    if(!player.hasPermission("permission.permission"){

    }
     
  3. Offline

    Trevor1134

    Garris0n I thought that, but "Player player = (Player)sender;"
    So the player would just be the player. I want to see if ANY user online has a permission to be exempt.
     
  4. Offline

    StrangeOne101

    I don't think you will be able to do it without editing the actual command.

    So a global mute command will probably fetch the player list off the server and apply it to all those players. There's nothing to stop it unless you override the command.
     
  5. Offline

    Chappro

    I don't think you explained that very well.
    Do you mean if any user has a certain permission, they all have the permission?

    EG:
    for(Player player : Bukkit.getOnlinePlayers()){
    if(!player.hasPermissions("permission.permission"){

    }
    }
     
  6. Offline

    Trevor1134

    Chappro
    How do I do it so when a user runs /globalmute, everyone EXCEPT PEOPLE WITH mute.bypass get muted.
     
  7. Offline

    StrangeOne101

    Is the command in your plugin or someone elses?
     
  8. Offline

    Skyshayde

    It would depend on how it is done. For example, you could have the command toggle a variable and then a PlayerChatEvent, check if the variable is true. And if so, cancel it if they don't have the permission.
     
  9. Offline

    Trevor1134

    Skyshayde I have done that, but my plugin wont load on the server? cant we take this to private chat so I can send you my .jar or what ever you need? IF YOU CAN HELP. Because no commands will work, it wont show up in /pl, and it doesn't enable in the console.
     
  10. Offline

    StrangeOne101

    Trevor1134 Your plugin.yml isn't correct then.
     
  11. Offline

    Trevor1134

  12. Offline

    Chappro

    Trevor1134

    Tell me how this works.
    I just quickly wrote this down and I don't know how it will work.
    You can work out where each method goes.
    Code:
        public static boolean gMute = false;
     
        @Override
        public boolean onCommand(CommandSender cs, Command cmnd, String string, String[] args) {
       
            Player player = (Player)cs;
       
            if (cmnd.getName().equalsIgnoreCase("globalmute"))
            {
                if(player.isOp()){
                    gMute = !gMute;
                    if(gMute == true){
                        Bukkit.broadcastMessage("The chat has been muted!");
                    }
                    else
                    {
                        Bukkit.broadcastMessage("The chat has been unmuted!");
                    }
                }
            }
        }
     
        @EventHandler
        public void onPlayerChatEvent(AsyncPlayerChatEvent event) {
     
            Player player = event.getPlayer();
            if(!player.hasPermission("mute.bypass") && (gMute == true))
            {
                player.sendMessage("The chat is currently muted!");
                event.setCancelled(true);
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page