mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Fix being able to negate permissions/parents/meta in specific contexts
This commit is contained in:
parent
fae49096f3
commit
030fb1262e
@ -489,8 +489,9 @@ public abstract class PermissionHolder {
|
||||
List<LocalizedNode> finalAccumulator = accumulator;
|
||||
|
||||
// this allows you to negate parent permissions lower down the inheritance tree.
|
||||
// we can negate parent groups in a specific context at this level and prevent them from being applied.
|
||||
// there's no way to distinct the stream below based on a custom comparator.
|
||||
NodeTools.removeIgnoreValue(nodes.iterator());
|
||||
NodeTools.removeSamePermission(nodes.iterator());
|
||||
|
||||
nodes.stream()
|
||||
.filter(Node::getValue)
|
||||
@ -612,6 +613,12 @@ public abstract class PermissionHolder {
|
||||
|
||||
// get and add the objects own nodes
|
||||
List<Node> nodes = flattenAndMergeNodesToList(context.getContextSet());
|
||||
|
||||
// this allows you to negate parent permissions lower down the inheritance tree.
|
||||
// it also allows you to negate meta in specific contexts and have it override.
|
||||
// there's no way to distinct the stream below based on a custom comparator.
|
||||
NodeTools.removeSamePermission(nodes.iterator());
|
||||
|
||||
nodes.stream()
|
||||
.filter(Node::getValue)
|
||||
.filter(n -> n.isMeta() || n.isPrefix() || n.isSuffix())
|
||||
@ -623,10 +630,6 @@ public abstract class PermissionHolder {
|
||||
accumulator.accumulateWeight(w.getAsInt());
|
||||
}
|
||||
|
||||
// this allows you to negate parent permissions lower down the inheritance tree.
|
||||
// there's no way to distinct the stream below based on a custom comparator.
|
||||
NodeTools.removeIgnoreValue(nodes.iterator());
|
||||
|
||||
nodes.stream()
|
||||
.filter(Node::getValue)
|
||||
.filter(Node::isGroupNode)
|
||||
|
@ -39,11 +39,11 @@ public class LogicParser {
|
||||
public static boolean parse(String s, PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
|
||||
try {
|
||||
ScriptEngine engine = Scripting.getScriptEngine();
|
||||
|
||||
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
|
||||
if (engine == null) {
|
||||
throw new NullPointerException("script engine");
|
||||
}
|
||||
|
||||
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
|
||||
String result = engine.eval(expression).toString();
|
||||
|
||||
if (!result.equals("true") && !result.equals("false")) {
|
||||
|
Loading…
Reference in New Issue
Block a user