Search in sources :

Example 6 with SubjectInheritanceGraph

use of me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph in project LuckPerms by lucko.

the class CalculatedSubject method resolveAllParents.

public Set<LPSubjectReference> resolveAllParents() {
    SubjectInheritanceGraph graph = SubjectInheritanceGraphs.getGraph();
    Set<LPSubjectReference> result = new LinkedHashSet<>();
    Iterable<CalculatedSubject> traversal = graph.traverse(TraversalAlgorithm.DEPTH_FIRST_PRE_ORDER, this);
    for (CalculatedSubject subject : traversal) {
        for (LPSubjectReference entry : subject.getCombinedParents()) {
            if (!result.contains(entry)) {
                result.add(entry);
            }
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) LPSubjectReference(me.lucko.luckperms.sponge.service.model.LPSubjectReference) SubjectInheritanceGraph(me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph)

Example 7 with SubjectInheritanceGraph

use of me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph in project LuckPerms by lucko.

the class CalculatedSubject method resolveAllPermissions.

public Map<String, Boolean> resolveAllPermissions() {
    SubjectInheritanceGraph graph = SubjectInheritanceGraphs.getGraph();
    Map<String, Boolean> result = new HashMap<>();
    Iterable<CalculatedSubject> traversal = graph.traverse(TraversalAlgorithm.DEPTH_FIRST_PRE_ORDER, this);
    for (CalculatedSubject subject : traversal) {
        for (Map.Entry<String, Boolean> entry : subject.getCombinedPermissions().entrySet()) {
            result.putIfAbsent(entry.getKey(), entry.getValue());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) SubjectInheritanceGraph(me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with SubjectInheritanceGraph

use of me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph in project LuckPerms by lucko.

the class CalculatedSubject method resolveAllOptions.

public Map<String, String> resolveAllOptions(ImmutableContextSet filter) {
    SubjectInheritanceGraph graph = SubjectInheritanceGraphs.getGraph(filter);
    Map<String, String> result = new HashMap<>();
    Iterable<CalculatedSubject> traversal = graph.traverse(TraversalAlgorithm.DEPTH_FIRST_PRE_ORDER, this);
    for (CalculatedSubject subject : traversal) {
        for (Map.Entry<String, String> entry : subject.getCombinedOptions(filter).entrySet()) {
            result.putIfAbsent(entry.getKey(), entry.getValue());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) SubjectInheritanceGraph(me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SubjectInheritanceGraph (me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 LinkedHashSet (java.util.LinkedHashSet)2 LPSubjectReference (me.lucko.luckperms.sponge.service.model.LPSubjectReference)2