Getting all the permissions nodes

Hey guys, I’m trying to get a list of all the permissions node but I’m not able to do so. I’m kinda new to Sponge coding so honestly I don’t know where to start looking.

Basically I wanna remove every permission nodes to Players and only adds the one that I want for them.

Also I was reading about the permission system with Sponge but I don’t get how I can add a persistent permission or a transient one.

Thanks for your help!

The starting point would be the permissions service, this is where all permission stuff is stored. If you have read the docs (sounds like you have) you will know how to get the object.

After that you need to get all subjects (subject meaning something that holds permissions) then get all the permissions from that subject which you will only be able to do by converting the subject into SubjectData.

Im on my phone so the code wont be a copy and paste job, but here is some code that will assist you.

Set<String> permissions = new HashSet<>();
Set<String> ids = permissionService.getAllIds().get();
for(String id : ids){
    SubjectCollection subCollection = permissionService.loadCollection(id).get();
    Set<String> subIds = subCollection.getAllIds().get();
    for(String subId : subIds){
        Subject subject = subCollection.loadSubject(subId).get();
        permissions.addAll(subject.getSubjectData().getAllPermissions().values().keySet());
1 Like

How does one get the instance of the permission service?

PermissionService permissionService = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getProvider();

Thanks man!