Solved Where do I add my permissions?

Discussion in 'Plugin Development' started by keaton64, May 27, 2014.

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

    keaton64

    So basically I have two listener classes that use permissions to determine what user can do what etc.
    It calls on hasPermission but when I throw any of my current permissions into PEX it throws about 70 errors and calls me an idiot. I think I have to use the addPermission function but where do I put it? I've tried putting it in my main class but it throws tons of errors. I'm really new to bukkit and am looking for some helpful advice.
    snipit of code
    Code:java
    1. if(!player.hasPermission("hunger.off")) {
    2. event.setCancelled(false);
    3. player.setFoodLevel(20);

    and the other snipit
    Code:java
    1. private boolean hasPermission(Player p){
    2. return p.hasPermission("sleep.sleep");


    getPluginManager().addPermission(new Permission(.....)) is the code but it throws me errors.
    Not sure if the code is outdated or if I'm challenged. I wrote the code, I'm 100% sure I didn't put any addPermissions in anywhere else.

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

    Necrodoom

    You dont need to do anything to have hasPermission work.
    Paste the error you are getting please.
     
  3. Offline

    Konkz

    PHP:
    if (bukkitPlayer.hasPermission("my.permission") {
    bukkitPlayer.sendMessage("You have the permission.");
    }
    else {
    bukkitPlayer.sendMEssage("Nu uh!");
    }
    If you have that and you don't do anything else, don't add it to plugin.yml, your on enable method etc. it will work.
     
  4. Offline

    mine-care

    Necrodoom
    As he said, post stacktrace
     
  5. Offline

    keaton64

  6. Offline

    FabeGabeMC

    keaton64 you dont need permissions.yml.
    I just check if the player has a perm, and it works...
     
  7. Offline

    Azubuso

    FabeGabeMC You have a tab somewhere in your "permissions.yml", YAML files can't contain any tab stops.
    Paste your YAML file into this and fix that little tab; http://yamllint.com/
     
  8. Offline

    keaton64

    How do I check if a player has a perm?
    And how do I know if my code works if I don't test it?
     
  9. Offline

    Necrodoom

    You already check permission properly. However, you broke your PEX permissions.yml, so do what Azubuso said,
     
  10. Offline

    keaton64

    I've fixed it all.
    I feel like I've accomplished so much so quickly. I want to thank all of you guys.
    I was yet again just being an idiot.
     
Thread Status:
Not open for further replies.

Share This Page