permission error

Discussion in 'Plugin Development' started by jobud9, Jan 25, 2012.

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

    jobud9

    When I type '/cb mute' it always says you don't have permission. I'm not getting any errors.
    onCommand:
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("cb")){
                if(args.length != 0){
                    if(args[0].matches("mute")){
                        if(perms.canMute(sender)){
                            if(args.length == 1){
                                sender.sendMessage(args[1]+" has been notified and Muted!");
                            }
                            else{
                                sender.sendMessage("please enter the name of the player being muted eg: ");
                                sender.sendMessage("/cb mute [player]");
                            }
                        }
                        else{
                            sender.sendMessage("You do not have permsion!");
                        }
                    }
                    else if(args[0].matches("about")){
                        sender.sendMessage(ChatColor.GREEN + this.pdfile.getName()+" version "+this.pdfile.getVersion());
                    }
                    else{
                        sender.sendMessage(ChatColor.RED+"Command not reconized: "+ cmd.getLabel());
                    }
                    return true;
                }
                else{
                    sender.sendMessage(ChatColor.GREEN + this.pdfile.getName()+" version "+this.pdfile.getVersion());
                    return true;
                }
     
            }
            return false;
        }
    perms implementation:
    Code:
    package me.JnH.ChatterBox;
     
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.Plugin;
     
    public class perms {
        private Plugin plugin;
        public perms(Plugin plugin){
            this.plugin = plugin;
        }
        public boolean canMute(CommandSender sender){
            if(sender.hasPermission("cbox.canmute")){
                return true;
            }
            else{
                return false;
            }
        }
    }
    
     
  2. Offline

    tomjw64

    jobud9 did you add the permission to the plugin.yml?
    Also, have you tried it as OP?
     
  3. Offline

    jobud9

    tomjw64
    yes I have tried it as both an op and as the console. I think my plugin.yml is setup right:
    Code:
    permissions:
        cbox.*:
            description: Default Chatterbox permisions.
            children:
                cbox.canmute: false
        cbox.canmute:
            description: Allows you to mute a player
            default: op
     
  4. Offline

    tomjw64

    I think it's a problem with this line:
    Code:
     if(perms.canMute(sender)){
    try just:
    Code:
    if(sender.hasPermission("cbox.canmute")){
     
  5. Offline

    jobud9

    that did not help. my problem with with
    Code:
        cbox.*:
            description: Default Chatterbox permisions.
            children:
                cbox.canmute: false
    cbox.canmute was set to false and it would not allow anyone to use it.
     
  6. Offline

    tomjw64

    Oh, I apologize that I couldn't be more helpful. I'm happy you figured it out though.
     
Thread Status:
Not open for further replies.

Share This Page