Solved Set list of permissions to player?

Discussion in 'Plugin Development' started by Xp10d3, Jan 27, 2020.

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

    Xp10d3

    Hello. I am trying to create a permissions plugin that is a bit like PermissionsEx for someone since I guess they don't want to use Vault or PEX. I was wondering if it is possible to set a player a list of permissions? I followed the Bukkit Wiki by using PermissionAttachment so that it looks like this:
    Code:
                        PermissionAttachment at = target.addAttachment(core);
                        playerPerms.put(target.getUniqueId(), at);
                        Set<String> keys = core.getConfig().getConfigurationSection(args[2]).getKeys(false);
                        for (String key : keys) {
                            List<String> list = core.getConfig().getStringList(args[2] + key);
                            at.setPermission(list, true);
                        }
    
    So my config looks like this:
    Code:
    Owner:
      - permission.node
      - permission.node.two
      - permission.node.*
    
    I want to get the group Owner and then get the list of permissions by looping it. But PermissionAttachment only allows me to set one attachment at a time, so I am wondering whether it's possible to assign permissions another way so that I can assign a list of them? Thanks!
    -Xp10d3
     
  2. Offline

    KarimAKL

    @Xp10d3 Just create a loop, like this:
    Code:Java
    1. for (String permission : config.getStringList("Owner")) attachment.setPermission(permission, true);
     
  3. Offline

    Xp10d3

    Thanks :) Thought that loops were involved xD
     
Thread Status:
Not open for further replies.

Share This Page