Search in sources :

Example 11 with LPSubjectReference

use of me.lucko.luckperms.sponge.service.model.LPSubjectReference in project LuckPerms by lucko.

the class CalculatedSubjectData method resolveParents.

public Set<LPSubjectReference> resolveParents(ContextSet filter) {
    // get relevant entries
    SortedMap<ImmutableContextSet, Set<LPSubjectReference>> sorted = new TreeMap<>(ContextSetComparator.reverse());
    for (Map.Entry<ImmutableContextSet, Set<LPSubjectReference>> entry : this.parents.entrySet()) {
        if (!entry.getKey().isSatisfiedBy(filter)) {
            continue;
        }
        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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) ContextSet(me.lucko.luckperms.api.context.ContextSet) LinkedHashSet(java.util.LinkedHashSet) LPSubjectReference(me.lucko.luckperms.sponge.service.model.LPSubjectReference) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) TreeMap(java.util.TreeMap) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Aggregations

LPSubjectReference (me.lucko.luckperms.sponge.service.model.LPSubjectReference)11 Map (java.util.Map)5 ImmutableContextSet (me.lucko.luckperms.api.context.ImmutableContextSet)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 LinkedHashSet (java.util.LinkedHashSet)4 HashMap (java.util.HashMap)3 Set (java.util.Set)2 SortedMap (java.util.SortedMap)2 TreeMap (java.util.TreeMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ContextSet (me.lucko.luckperms.api.context.ContextSet)2 SubjectInheritanceGraph (me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Node (me.lucko.luckperms.api.Node)1 InheritanceGraph (me.lucko.luckperms.common.inheritance.InheritanceGraph)1