use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class NodeMap method clear.
void clear(ContextSet contextSet) {
this.lock.lock();
try {
ImmutableContextSet context = contextSet.makeImmutable();
this.map.removeAll(context);
this.inheritanceMap.removeAll(context);
} finally {
this.lock.unlock();
}
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class NodeMap method remove.
void remove(Node node) {
this.lock.lock();
try {
ImmutableContextSet context = node.getFullContexts().makeImmutable();
this.map.get(context).removeIf(e -> e.equals(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE));
if (node.isGroupNode()) {
this.inheritanceMap.get(context).removeIf(e -> e.equals(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE));
}
} finally {
this.lock.unlock();
}
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class NodeMap method removeExact.
private void removeExact(Node node) {
this.lock.lock();
try {
ImmutableContextSet context = node.getFullContexts().makeImmutable();
this.map.remove(context, node);
if (node.isGroupNode() && node.getValuePrimitive()) {
this.inheritanceMap.remove(context, node);
}
} finally {
this.lock.unlock();
}
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class CalculatedSubjectData method resolveParents.
public Set<LPSubjectReference> resolveParents() {
// get relevant entries
SortedMap<ImmutableContextSet, Set<LPSubjectReference>> sorted = new TreeMap<>(ContextSetComparator.reverse());
for (Map.Entry<ImmutableContextSet, Set<LPSubjectReference>> entry : this.parents.entrySet()) {
sorted.put(entry.getKey(), entry.getValue());
}
// flatten
Set<LPSubjectReference> result = new LinkedHashSet<>();
for (Set<LPSubjectReference> set : sorted.values()) {
for (LPSubjectReference e : set) {
if (!result.contains(e)) {
result.add(e);
}
}
}
return result;
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class HolderSubjectData method getAllOptions.
@Override
public ImmutableMap<ImmutableContextSet, ImmutableMap<String, String>> getAllOptions() {
Map<ImmutableContextSet, Map<String, String>> options = new HashMap<>();
Map<ImmutableContextSet, Integer> minPrefixPriority = new HashMap<>();
Map<ImmutableContextSet, Integer> minSuffixPriority = new HashMap<>();
for (Node n : this.holder.getNodes(this.type).values()) {
if (!n.getValuePrimitive())
continue;
if (!n.isMeta() && !n.isPrefix() && !n.isSuffix())
continue;
ImmutableContextSet immutableContexts = n.getFullContexts().makeImmutable();
if (!options.containsKey(immutableContexts)) {
options.put(immutableContexts, new HashMap<>());
minPrefixPriority.put(immutableContexts, Integer.MIN_VALUE);
minSuffixPriority.put(immutableContexts, Integer.MIN_VALUE);
}
if (n.isPrefix()) {
Map.Entry<Integer, String> value = n.getPrefix();
if (value.getKey() > minPrefixPriority.get(immutableContexts)) {
options.get(immutableContexts).put(NodeFactory.PREFIX_KEY, value.getValue());
minPrefixPriority.put(immutableContexts, value.getKey());
}
continue;
}
if (n.isSuffix()) {
Map.Entry<Integer, String> value = n.getSuffix();
if (value.getKey() > minSuffixPriority.get(immutableContexts)) {
options.get(immutableContexts).put(NodeFactory.SUFFIX_KEY, value.getValue());
minSuffixPriority.put(immutableContexts, value.getKey());
}
continue;
}
if (n.isMeta()) {
Map.Entry<String, String> meta = n.getMeta();
options.get(immutableContexts).put(meta.getKey(), meta.getValue());
}
}
ImmutableMap.Builder<ImmutableContextSet, ImmutableMap<String, String>> map = ImmutableMap.builder();
for (Map.Entry<ImmutableContextSet, Map<String, String>> e : options.entrySet()) {
map.put(e.getKey(), ImmutableMap.copyOf(e.getValue()));
}
return map.build();
}
Aggregations