diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java index ba05f8d..5752844 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java @@ -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 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 don’t explicitely inherit from at least one group.