Solved hasPermission not working

Discussion in 'Plugin Development' started by haussik, Sep 25, 2016.

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

    haussik

    I've been trying to add permissions to my plugin for a while, and it's really pissing me off. Even if a player has the correct permission, they can't use the command if they're not an OP.

    Here's the code:
    Code:
    //onCommand stuff here
    
    if(sender.hasPermission("lyc.joueur.lune"))
                        {
                            if(args.length == 1)
                            {
                                if(args[0].equalsIgnoreCase("lune")) //if they typed "/lyc lune"
                                {
                                    //Do stuff here
                                }
                            }
                        }
                        else
                        {
                            sender.sendMessage(ChatColor.RED + "Nope!");
                            return true;
                        }
    Here's the plugins.yml file:
    Code:
    name: Lycanthrope
    description: Plugin fait par Chargon
    main: com.chargon.werewolf.Main
    version: 1.9-3
    depend: [PermissionsEx]
    commands:
    lyc:
      description: Commande de base
      usage: Mauvais usage de la commande!
    And here's the permission file:
    Code:
    groups:
      default:
        options:
          default: true
        permissions:
        - modifyworld.*
        - lyc.joueur.lune
    Thanks for helping me :x
     
  2. Offline

    Whoneedspacee

    I don't know why you cut out parts like // OnCommand stuff, or why you felt like you needed to, but a guess is that you forgot to check what command they were actually using, otherwise that it probably has something to do with your permissions / yml files, though you get errors from those problems so I doubt it.

    Just trying to guess but I really have no idea.
     
    haussik likes this.
  3. Offline

    haussik

    Actually, i checked another command with an args.lenght of 1 before this one and it caused trouble, thanks tho! :D
     
  4. Offline

    JanTuck

    Try making a new permission

    Permission perm = new Permission(string);

    Player.hasPermission(perm);

    Sent from Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page