Search in sources :

Example 6 with InheritanceGraph

use of me.lucko.luckperms.common.inheritance.InheritanceGraph in project LuckPerms by lucko.

the class PermissionHolder method accumulateMeta.

public MetaAccumulator accumulateMeta(MetaAccumulator accumulator) {
    if (accumulator == null) {
        accumulator = MetaAccumulator.makeFromConfig(this.plugin);
    }
    InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph();
    Iterable<PermissionHolder> traversal = graph.traverse(this.plugin.getConfiguration().get(ConfigKeys.INHERITANCE_TRAVERSAL_ALGORITHM), this);
    for (PermissionHolder holder : traversal) {
        List<Node> nodes = holder.getOwnNodes();
        for (Node node : nodes) {
            if (!node.getValuePrimitive())
                continue;
            if (!node.isMeta() && !node.isPrefix() && !node.isSuffix())
                continue;
            accumulator.accumulateNode(ImmutableLocalizedNode.of(node, holder.getObjectName()));
        }
        OptionalInt w = getWeight();
        if (w.isPresent()) {
            accumulator.accumulateWeight(w.getAsInt());
        }
    }
    return accumulator;
}
Also used : LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) Node(me.lucko.luckperms.api.Node) OptionalInt(java.util.OptionalInt) InheritanceGraph(me.lucko.luckperms.common.inheritance.InheritanceGraph)

Aggregations

InheritanceGraph (me.lucko.luckperms.common.inheritance.InheritanceGraph)6 LocalizedNode (me.lucko.luckperms.api.LocalizedNode)4 Node (me.lucko.luckperms.api.Node)4 ImmutableLocalizedNode (me.lucko.luckperms.common.node.ImmutableLocalizedNode)4 OptionalInt (java.util.OptionalInt)2 Group (me.lucko.luckperms.common.model.Group)2 PermissionHolder (me.lucko.luckperms.common.model.PermissionHolder)2 ImmutableList (com.google.common.collect.ImmutableList)1 Contexts (me.lucko.luckperms.api.Contexts)1 SpongeGroup (me.lucko.luckperms.sponge.model.SpongeGroup)1 LPSubjectReference (me.lucko.luckperms.sponge.service.model.LPSubjectReference)1