1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Not a Bug Sender hasPermissions() is always false.

Discussion in 'Bugs & Feature Requests' started by MrThunder_, Jul 13, 2015.

  1. Sender sender, can't be checked for permissions. How to repeat? Use this code below:
    Code (Text):
        private boolean hasPermission(CommandSender sender, String perms){
            if (!sender.hasPermission(perms) || !sender.isOp()){
                sender.sendMessage(ChatColor.RED + "You don't have permissions!");
                return false;
            } else {
                return true;
            }
        }
    Only, player.hasPermissions works, sender.hasPermissions not.
     
  2. My temporary fix:
    Code (Text):
        private boolean hasPermission(CommandSender sender, String perms){
            if (!(sender instanceof Player)){
                return true; //console always must have access
            }
            Player player = (Player) sender;
            if (!player.hasPermission(perms) || !player.isOp()){
                sender.sendMessage(Iceball.pluginPrefix + ChatColor.RED + "You don't have permissions!");
                return false;
            } else {
                return true;
            }
     
  3. Code (Text):

       private boolean hasPermission(CommandSender sender, String perms){
            if (!(sender instanceof Player)){
                return true; //console always must have access
            }
            Player player = (Player)sender;
            if (!player.hasPermission("perms") || !player.isOp()){
                sender.sendMessage(Iceball.pluginPrefix + ChatColor.RED + "You don't have permissions!");
                return false;
            } else {
                return true;
            }
     
    That must work! ;-)
     
  4. No need to do silly cast etc. sender.hasPermission works.

    But your if will always execute if the sender is not op. That's your problem.
     
  5. Wow, hahaha. *awkward*