I need some help with PermissionsBukkit

Discussion in 'Plugin Development' started by Uhehesh, Sep 23, 2011.

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

    Uhehesh

    Hello.

    I use PermissionsBukkit, and I need to get all the permissions of player. How?
    Or how can I get group of player?

    Thank you.

    bump

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

    Baummann

    @Uhehesh
    Code:java
    1. //Returns PermissionsBukkit's configuration file
    2. public Configuration config() {
    3. Configuration config = new Configuration("plugins/PermissionsBukkit/config.yml");
    4. config.load();
    5. Configuration c = config;
    6. config.save();
    7. return c;
    8. }
    9.  
    10. //Returns all permissions a player has in a linked hash map
    11. public LinkedHashMap<String, Boolean> getPermissions(Player player) {
    12. Configuration config = config();
    13. config.load();
    14. LinkedHashMap<String, Boolean> map = config.getProperty("users." + player.getName() + ".permissions");
    15. if (map == null) map = new LinkedHashMap<String, Boolean>();
    16. config.save();
    17. return map;
    18. }
    19.  
    20. //Returns all the groups a player has in a list
    21. public ArrayList<String> getGroups(Player player) {
    22. Configuration config = config();
    23. config.load();
    24. ArrayList<String> list = config.getProperty("users." + player.getName() + ".groups");
    25. if (list == null) list = new ArrayList<String>();
    26. config.save();
    27. return list;
    28. }
     
    Uhehesh likes this.
  3. Offline

    krinsdeath

    @Uhehesh

    Code:
    Set<PermissionAttachmentInfo> atts =  player.getEffectivePermissions();
    Collections.sort(atts, new Comparator<PermissionAttachmentInfo>() {
      public int compare(PermissionAttachmentInfo a, PermissionAttachmentInfo b) {
        return a.getPermission().compareTo(b.getPermission());
      }
    });
    for (PermissionAttachmentInfo info : atts) {
      System.out.println(player.getName() + ": " +  info.getPermission());
    }
    
     
    Uhehesh likes this.
  4. Offline

    Uhehesh

    Thank you krinsdeath! (how to tag users?)
    You helped me very much.

    And you Baummann just re-invented wheel. :p
    But thank you too.
     
Thread Status:
Not open for further replies.

Share This Page