From f305f8d82277b34b63ec18ad7efd2849e31a4f99 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 15 Apr 2017 19:08:04 +0100 Subject: [PATCH] Determine dynamic primary groups using current context --- .../common/primarygroup/AllParentsByWeightHolder.java | 3 ++- .../luckperms/common/primarygroup/ParentsByWeightHolder.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java index 554c8394..82c987a9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java @@ -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()))) diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java index d5ac015a..58488462 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java @@ -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())))