List of all the permission of a plugin

Discussion in 'Plugin Development' started by Nic2555, Dec 10, 2014.

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

    Nic2555

    hey guys, I would like to know if it's possible to get the permission node of a plugins and print it, in java.
    like a system.out.println.
    I would use them after and push them into an arrayList. Is that possible ?
    Thanks !

    - Nic.
     
  2. Offline

    Skionz

  3. Offline

    fireblast709

    @Nic2555 if the developer lists them in their plugin.yml, you could use that. Otherwise, it will involve a lot of guess work (if you are lucky. They might not register them at all and just use some 'arbitrary' hardcoded permission)
     
  4. Offline

    Avygeil

    @Nic2555
    As @fireblast709 said, you can use JavaPlugin#getDescription() and then getPermissions() to list those in plugin.yml. You have access to even more information with this class. But chances are that you won't retrieve all permissions.

    It was not for permissions, but I did something similar in the past. If you absolutely need permissions, you could use ASM and hook methods like "hasPermission()" or similar methods from Vault, and add a profiler registering every call in sync with your main class to check what command does what (with a command preprocess for example), and determine the associated plugin with bukkit's commandMap. The result would be a lazy initialized Map of permissions. While it would work for commands (even though in case of subcommands in the same onCommand, you can't really make a link), it certainly can't sync with events (or anything that's not a command) easily, and it cannot catch everything either.

    It's probably too complicated for not much in the end, up to you to see if it's worth it. But it works pretty well for a plugin analysis tool. :)
     
  5. Offline

    Nic2555

    Do you have any exemple of how i could just push them into an arrayList ?
    ( I'm kinda new to java. It's my first semester in Java, be gentle :))
    Thanks

    Nic,.
     
  6. Offline

    Skionz

    @Nic2555 Example:
    Code:
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(1);
    list.add(2);
     
  7. Offline

    Nic2555

    Ok, let me explain my self a bit. Haha
    what I need, is a function, that will return me every permission nodes into an array list. I know how to add items in those and how to use them. All I need is to get the permission node ,which could be a string, into my arrayList, so i could use it after.
    If You still got interogation check this out;
    Code:
    public void getPermission(){
         ArrayList() permission = new ArrayList();
         String permissionNodes =    bukkit.getPluginsManager().getPermission.getName();
         permission.add(permissionNodes);
    }
    Thanks

    Nic.
     
  8. @Nic2555 This isn't possible. It's possible to get some as has already been mentioned above, but it'll be impossible to get every single one without missing some. (Unreliable hacky methods excluded, but even they wouldn't be perfect)
     
Thread Status:
Not open for further replies.

Share This Page