Adding Permissions. Help.

Discussion in 'Plugin Development' started by TheLazeboy, Jan 2, 2013.

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

    TheLazeboy

    How would I add a permission? For example the node would be "superpowers.heal", would that node allow the "/heal" command and the alternate "/spheal" command? How would I make it so? Please be simple and explain your answer. :)
     
  2. Offline

    Tirelessly

    In the onCommand you can just do if(player.hasPermission("superpowers.heal"))
     
  3. Offline

    keelar

    I think he's asking how to add a permission, not check if a player has a permission. If so, this page explains everything you need to know.
     
  4. Offline

    TheLazeboy

    Just to check, that shows me how to add a permission to my plugin, not make a permission plugin, right?
     
  5. Offline

    MrlolDestructo

    No, that site is for making a permissions plugin. Tirelessly was right. To make it so that someone has to have a permission to run a command or do something or whatever, you do if(player.hasPermission("<probably want your plugin name here>.<probably the name of whatever this is doing>"). For example, as Tirelessly said, if(player.hasPermission("superpowers.heal") is an ideal one.
     
  6. Offline

    keelar

    He said
    so I immediately assumed he wanted to "add a permission." I know that page shows how to make a permission plugin. Adding a permission is not the same as checking to see if a player HAS a permission.
     
  7. Offline

    TheLazeboy

    Yes, I understand how to check if a player has a permission, what I don't understand, like you said, is how to add a permission.
     
  8. Offline

    keelar

    Exactly. Check the link in my first comment.
     
  9. Offline

    Jogy34

    You have to add it to your plugin.yml.
    http://wiki.bukkit.org/Plugin_YAML
    There is an example at the bottom
     
  10. Offline

    TheLazeboy

    So how? :p I know really nothing about Java.
     
  11. Offline

    keelar

    I'm a bit confused on what you want. Do you want to add permissions to certain players like a permissions plugin would or just require a permission to use a command?
     
  12. Offline

    Jogy34

    First off the plugin.yml isn't java it is a different file that you need in your plugin's .jar in order for the bukkit server to know that isn't a plugin.

    Second you should learn at least the basics of java before attempting to make a bukkit plugin
     
  13. Offline

    TheLazeboy

    Okay, first off, I know the basics I just don't know permissions.
    Second off, I know it's a different file, jar and yml are not the same obviously.
     
  14. Offline

    Jogy34

    Ok. To check if a player has a permission you just do this as said above
    Code:
    if(player.hasPermission("Your.Perm.Ission"))
    {
        //do stuff
    }
    
    then you need to actually add the permission to your plugin.yml file so that the server knows that it is a permission. This is where the link that I gave you comes in but I guess that you didn't actually look at it so you would add this to your plugin.yml to add the permission above:
    Code:
    permissions:
        Your.Perm.Ission:
            default: op //This can be false (no one get's the permission by default) or true (everyone get's it by default) or op (op's get it by default)
     
  15. Offline

    TheLazeboy

    I think the require a permission to use a command? My plugin I'm working on is for superpowers, but I want the powers to act a bit like "Jobs" plugin.

    If they were for example, a healer then they would only be able to use the "/heal" command. If it were a flyer then they would only be able to use the "/fly" command.
     
  16. Offline

    tommycake50

    actually jogy you dont :p.
    none of my plugins have the permissions in their plugin.yml files.
    i just don't like all dat writing.
     
  17. Offline

    Jogy34

    If you don't put it in your plugin.yml then you have to add them in code which is only a little less writing
     
  18. Offline

    TheLazeboy

    Okay well, here is the console error.
    [​IMG]
    And just as a side note, I love Blothera Kingdom. :p
     
  19. Offline

    tommycake50

    meh but the thing is when you have to register different permissions for different args and just not 1 general permission.
    i just prefer doing it in code.
     
  20. Offline

    TheLazeboy

    I wanna try it your way.
     
  21. Offline

    Jogy34

    I only do it in code when I do something that makes it so there isn't a definite number of permissions.
    Looks like you are trying to register the permission twice. Also thanks

    to add permissions in code you do:
    Code:
    this.getServer().getPluginManager().addPermission(new Permission("Your.Perm.Ission"));
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 8, 2016
  22. Offline

    TheLazeboy

    Does that go in my onEnable or onDisable?
     
  23. Offline

    Jogy34

    onEnable(), sorry forgot to mention that
     
  24. Offline

    EnvisionRed

    Do you even really need to ask that? Do you think that code would work better if it was run when your plugin enables or when your plugin disables?
     
  25. Offline

    TheLazeboy

    :3 Okay yea looking at it now, I realize that was kind of stupid. Thank you for your valuable input to the issue.
     
  26. Offline

    Tirelessly

    You never need to add permissions... Not in plugin.yml, not in onEnable.
    (this.getServer().getPluginManager().addPermission(new Permission("Your.Perm.Ission"));)


    You can just check them.
     
  27. Offline

    Jogy34

    Every time that I have ever forgotten to add a permission to the plugin.yml it has failed so I'm going to stick with doing adding them.
     
  28. Offline

    TheLazeboy

    Here is my console error.
    [​IMG]

    Here is my "Permissions" class.
    http://pastebin.com/vEm0YUXe
     
  29. Offline

    EnvisionRed

    Please, read the Stickied thread about reading your own stack traces. They look complicated and are in fact quite easy to read. That error has nothing to do with your Permissions class.
     
  30. Offline

    Jogy34

    That has nothing to do with your permissions class. It can't find your main class that you specified in your plugin.yml. It threw a ClassNotFoundException. And ya what EnvisionRed said read this.
     
Thread Status:
Not open for further replies.

Share This Page