Solved Is this possible?

Discussion in 'Plugin Development' started by mazentheamazin, Jan 6, 2014.

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

    mazentheamazin

    Hi,

    I was wondering, would it be possible to check if a player does/doesn't have a list of permissions?

    Any help will be appreciated,
    Mazen
     
  2. mazentheamazin
    Are you trying to add a permission to something or are you trying to check if the player has permissions?
     
  3. Offline

    mazentheamazin

    Cooper PluginDev
    Well, I am looking to check if a player doesn't have a permission node from a list of permissions.
     
  4. mazentheamazin
    Aww, not sure how you would go about doing that, you could just do if (player.hasPermission("(blabla.blabla")); and do that for all the permissions.
     
  5. Offline

    mazentheamazin

    Cooper PluginDev
    Well, the problem is.. The permissions I am looking for, are based of something in the config. Like for example:
    Code:java
    1. if(player.hasPermission("plugin." + getConfig().getString("cmd.permission"){
    2. //blah code blah.
    3. }
     
  6. Offline

    hintss

    so just do that? (plus the missing parens, ofc)
     
  7. Offline

    mazentheamazin

    hintss
    Oh whoops. I ment getConfig().getStringList("cmd.permission")
     
  8. Offline

    hintss

    so...just loop through the list? I don't see the issue
     
  9. Offline

    Pew446

    Not sure exactly what your goal is, but here's how you would loop through the permissions in the config:

    Code:java
    1. List<String> permList = getConfig().getStringList("foo.bar");
    2.  
    3. for(String perm : permList)
    4. {
    5. if(player.hasPermission("plugin."+perm))
    6. {
    7. //dostuff
    8. }
    9. }
     
    mazentheamazin likes this.
  10. Offline

    RawCode

    Implementation based on plugin hosting permissions...

    PermissionsEx allows to list\enum\iterate permisions of player by API and explained how to in documentation, other plugins may act differently.
     
Thread Status:
Not open for further replies.

Share This Page