Determine dynamic primary groups using current context

This commit is contained in:
Luck 2017-04-15 19:08:04 +01:00
parent 1f54bc41cc
commit f305f8d822
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 5 additions and 2 deletions

View File

@ -51,7 +51,8 @@ public class AllParentsByWeightHolder extends StoredHolder {
return cachedValue;
}
cachedValue = user.resolveInheritancesAlmostEqual(ExtractedContexts.generate(Contexts.allowAll())).stream()
Contexts contexts = user.getPlugin().getContextForUser(user);
cachedValue = user.resolveInheritancesAlmostEqual(ExtractedContexts.generate(contexts)).stream()
.filter(Node::isGroupNode)
.filter(Node::getValue)
.map(n -> Optional.ofNullable(user.getPlugin().getGroupManager().getIfLoaded(n.getGroupName())))

View File

@ -25,6 +25,7 @@
package me.lucko.luckperms.common.primarygroup;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.core.model.User;
@ -49,7 +50,8 @@ public class ParentsByWeightHolder extends StoredHolder {
return cachedValue;
}
cachedValue = user.mergePermissionsToList().stream()
Contexts contexts = user.getPlugin().getContextForUser(user);
cachedValue = user.flattenAndMergeNodesToList(contexts.getContexts()).stream()
.filter(Node::isGroupNode)
.filter(Node::getValue)
.map(n -> Optional.ofNullable(user.getPlugin().getGroupManager().getIfLoaded(n.getGroupName())))