From 9715c5394cdfbca1ff05d82511e1bd0ca1cc2884 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 18 Apr 2017 17:11:07 +0100 Subject: [PATCH] Fix NPE caused by AllParentsByWeight primary group selector - closes #252 --- .../primarygroup/AllParentsByWeightHolder.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 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 a2e29865..08034906 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 @@ -29,7 +29,7 @@ import lombok.NonNull; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.context.ContextSet; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.utils.ExtractedContexts; @@ -55,8 +55,19 @@ public class AllParentsByWeightHolder extends StoredHolder { } Contexts contexts = user.getPlugin().getContextForUser(user); - ContextSet contextSet = contexts != null ? contexts.getContexts() : user.getPlugin().getContextManager().getStaticContexts(); - cachedValue = user.resolveInheritancesAlmostEqual(ExtractedContexts.generate(contextSet)).stream() + if (contexts == null) { + contexts = new Contexts( + user.getPlugin().getContextManager().getStaticContexts(), + user.getPlugin().getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS), + user.getPlugin().getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS), + true, + user.getPlugin().getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS), + user.getPlugin().getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS), + false + ); + } + + cachedValue = user.resolveInheritancesAlmostEqual(ExtractedContexts.generate(contexts)).stream() .filter(Node::isGroupNode) .filter(Node::getValue) .map(n -> Optional.ofNullable(user.getPlugin().getGroupManager().getIfLoaded(n.getGroupName())))