added method in PermGroup to get groups that inherit the current group

This commit is contained in:
Marc Baloup 2022-11-30 13:35:34 +01:00
parent 41878b72f9
commit 862c164cf3
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893

View File

@ -1,5 +1,6 @@
package fr.pandacube.lib.permissions;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -35,6 +36,17 @@ public final class PermGroup extends PermEntity {
.collect(Collectors.toList());
}
/**
* Gets all the groups that directly inherits from this group.
* @return the groups that directly inherits from this group.
*/
public List<PermGroup> getInheritedGroups() {
CachedGroup thisCG = getBackendEntity();
return fromCachedGroups(Permissions.backendReader.getGroups().stream()
.filter(cg -> cg.inheritances.contains(thisCG))
.toList());
}
/**
* Tells if this group is a default group.
* A player inherits all default groups when they dont explicitely inherit from at least one group.