Solved Defining permission wildcards without plugin.yml

Discussion in 'Spigot Plugin Development' started by Islandscout, Jul 9, 2018.

  1. I'm currently working on a plugin and I've stumbled on how I should handle permissions. My plugin has a config containing a list of special items that a player can purchase given that they have the required permission to buy that item.

    Here's an example of permissions corresponding to a list of these special items:
    How would I make a decent wildcard system so that* grants the player permission to buy all items in a list? Is there already one that I can use?

    Defining wildcards in the plugin.yml is probably not an option, since the list is fully configurable.
  2. Aeternum


    You do not have to implement wildcards. For example lets say you have the following four permissions:

    When a player does an action that requires a permission be checked, it says okay, so player needs in order to complete this action, it goes through the players perms and if it sees then it grants it but if it finds*
    Then it says okay as long as the permission the player has to have matches everything up to the wildcard, then they have the permission.

    Not only do you not have to define wildcards, but there is not really a way TOO define wildcards in a plugin.
  3. That's the thing I'm having trouble with. The permissions should depend on whatever is put into the list in the configuration.

    If "coolthingy" is listed in the config, then* should allow the user to buy a "coolthingy". I really don't feel like defining a permission for every possible name someone can come up with.
  4. Aeternum


    No, the permission plugin never touches your plugin.yml, well my new web dashboard on pex does, but thats to list perms of installed plugins.
    Permissions plugins go solely off the node you are checking and the node they have in the permission plugins config
    You cant and dont determine anything about wildcards.
    If i set a bunch of permissions in your plugin called things like

    And then i give my player cake.*
    The permissions plugin will verify that permission when they are checked for it.
  5. Checking permission through hasPermission or through vault for example automatically handles the wildcard for you, just use the permission nodes like normal.
  6. Aeternum


    All you are doing is saying
    if user has perm
    then do this

    spigot and bukkit hook into any installed permission managers, and pass that check onto the permission plugin. It handles it. You dont do anything.
  7. Aw man. I could've sworn that I had to go into plugin.yml and define something like some.permission.* and list a bunch of children.
    • Winner Winner x 1
  8. No...
  9. Aeternum


    And development requires tact, and no small amount of lazyness. You import a dictionary and a random generator, instead of writing every one of 10^99 combonations down :^)
  10. Aeternum


    Yes, if your plugin has a bunch of commands and arguments, you are supposed to list the commands and arguments, and if you have a bunch of permissions and child permissions, you are supposed to register them all in your plugin.yml. but not for the purpose of wildcards or anything to do with permissions checks, but for proper documentation, and I personally look up each plugins perms in their plugin.yml so that i can list them in the dashboard:
  11. I still don't get it. I just gave myself a permission like* and apparently, hasPermission("") returns false.

    I'm using... GroupManager. But it notifies me that I already have the permission because I have*. When I give myself, the hasPermission method returns true.

    I haven't registered any permissions in my plugin.yml and I have no intentions to do so.
  12. Aeternum


    Well, stop using group manager, it has loads of its own issues. Use PermissionsEx or LuckPerms
    Especially luck perms if you need bungee, i dont support bungee anymore.
    • Winner Winner x 1
  13. Holy crap, it works!