getGroup methods should not include inherited groups

This commit is contained in:
Luck 2016-08-29 22:03:10 +01:00
parent 75858c1555
commit 4b67913eee
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 9 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.events.GroupAddEvent;
import me.lucko.luckperms.api.implementation.internal.GroupLink;
import me.lucko.luckperms.api.implementation.internal.PermissionHolderLink;
@ -321,10 +322,11 @@ public class Group extends PermissionHolder implements Identifiable<String> {
*/
private List<String> getGroups(String server, String world, boolean includeGlobal) {
// Call super #getPermissions method, and just sort through those
Map<String, Boolean> perms = exportNodes(server, world, null, includeGlobal, true, null);
return perms.keySet().stream()
.filter(s -> Patterns.GROUP_MATCH.matcher(s).matches())
.map(s -> Patterns.DOT.split(s, 2)[1])
return getNodes().stream()
.filter(n -> n.shouldApplyOnWorld(world, includeGlobal, true))
.filter(n -> n.shouldApplyOnServer(server, includeGlobal, true))
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toList());
}
}

View File

@ -329,7 +329,9 @@ public abstract class User extends PermissionHolder implements Identifiable<UUID
*/
public List<String> getGroups(String server, String world, boolean includeGlobal) {
// Call super #getPermissions method, and just sort through those
return getAllNodesFiltered(server, world, Collections.emptyMap(), includeGlobal, true).stream()
return getNodes().stream()
.filter(n -> n.shouldApplyOnWorld(world, includeGlobal, true))
.filter(n -> n.shouldApplyOnServer(server, includeGlobal, true))
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toList());