mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Refactor meta accumulation
This commit is contained in:
parent
d320679f69
commit
0c33b26fa9
@ -24,6 +24,7 @@ package me.lucko.luckperms.common.caching;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -38,4 +39,27 @@ public class MetaHolder {
|
||||
private final SortedMap<Integer, String> prefixes = new TreeMap<>(Comparator.reverseOrder());
|
||||
private final SortedMap<Integer, String> suffixes = new TreeMap<>(Comparator.reverseOrder());
|
||||
|
||||
public void accumulateNode(Node n) {
|
||||
if (n.isMeta()) {
|
||||
Map.Entry<String, String> entry = n.getMeta();
|
||||
if (!meta.containsKey(entry.getKey())) {
|
||||
meta.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (n.isPrefix()) {
|
||||
Map.Entry<Integer, String> value = n.getPrefix();
|
||||
if (!prefixes.containsKey(value.getKey())) {
|
||||
prefixes.put(value.getKey(), value.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (n.isSuffix()) {
|
||||
Map.Entry<Integer, String> value = n.getSuffix();
|
||||
if (!suffixes.containsKey(value.getKey())) {
|
||||
suffixes.put(value.getKey(), value.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -220,8 +220,6 @@ public abstract class PermissionHolder {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (work) {
|
||||
@ -309,29 +307,6 @@ public abstract class PermissionHolder {
|
||||
return all;
|
||||
}
|
||||
|
||||
private static void accumulateMetaNode(Node n, MetaHolder holder) {
|
||||
if (n.isPrefix()) {
|
||||
Map.Entry<Integer, String> value = n.getPrefix();
|
||||
if (!holder.getPrefixes().containsKey(value.getKey())) {
|
||||
holder.getPrefixes().put(value.getKey(), value.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (n.isSuffix()) {
|
||||
Map.Entry<Integer, String> value = n.getSuffix();
|
||||
if (!holder.getSuffixes().containsKey(value.getKey())) {
|
||||
holder.getSuffixes().put(value.getKey(), value.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (n.isMeta()) {
|
||||
Map.Entry<String, String> meta = n.getMeta();
|
||||
if (!holder.getMeta().containsKey(meta.getKey())) {
|
||||
holder.getMeta().put(meta.getKey(), meta.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MetaHolder accumulateMeta(MetaHolder holder, List<String> excludedGroups, Contexts context) {
|
||||
if (holder == null) {
|
||||
holder = new MetaHolder();
|
||||
@ -359,7 +334,7 @@ public abstract class PermissionHolder {
|
||||
if (!n.shouldApplyOnWorld(world, context.isIncludeGlobalWorld(), false)) continue;
|
||||
if (!n.shouldApplyWithContext(contexts, false)) continue;
|
||||
|
||||
accumulateMetaNode(n, holder);
|
||||
holder.accumulateNode(n);
|
||||
}
|
||||
|
||||
Set<Node> parents = all.stream()
|
||||
|
Loading…
Reference in New Issue
Block a user