PermissionsEx

PermissionsEx

14M Downloads

getting Permission Groups for Sponge

Nafi-R opened this issue ยท 1 comments

commented

How do you get a specific player's permission group. I'm familiar with spigot's implementation which is:
PermissionUser player = PermissionsEx.getUser(targetPlayer)
player.getGroups()
but I'm unsure with Sponge. Is there a similar implementation for sponge? And if so, where can I find more documentation about it.

Thanks

commented

Use Sponge's Permissions API -- It's documented in Sponge's documentation.

Generally, what you'd do is something like:

public List<Subject> getGroups(Subject user) {
    final PermissionService serv = this.service; // pre-collected variable
    return user.getParents().stream()
        .filter(subj -> subj.getContainingCollection().equals(serv.getGroupsGollection()))
        .collect(Collectors.toList());
}