use of me.lucko.luckperms.sponge.service.model.LPSubjectReference in project LuckPerms by lucko.
the class SubjectReferenceFactory method obtain.
public LPSubjectReference obtain(LPSubject subject) {
Objects.requireNonNull(subject, "subject");
LPSubjectReference ret = obtain(subject.getParentCollection().getIdentifier(), subject.getIdentifier());
((CachedSubjectReference) ret).fillCache(subject);
return ret;
}
use of me.lucko.luckperms.sponge.service.model.LPSubjectReference in project LuckPerms by lucko.
the class CalculatedSubject method getCombinedParents.
public Set<LPSubjectReference> getCombinedParents() {
Set<LPSubjectReference> parents;
Set<LPSubjectReference> merging;
switch(getParentCollection().getResolutionOrder()) {
case TRANSIENT_FIRST:
parents = getTransientSubjectData().resolveParents();
merging = getSubjectData().resolveParents();
break;
case TRANSIENT_LAST:
parents = getSubjectData().resolveParents();
merging = getTransientSubjectData().resolveParents();
break;
default:
throw new AssertionError();
}
for (LPSubjectReference entry : merging) {
if (!parents.contains(entry)) {
parents.add(entry);
}
}
return parents;
}
use of me.lucko.luckperms.sponge.service.model.LPSubjectReference 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.sponge.service.model.LPSubjectReference in project LuckPerms by lucko.
the class HolderSubject method getParents.
@Override
public ImmutableList<LPSubjectReference> getParents(ImmutableContextSet contexts) {
InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph(this.plugin.getContextManager().formContexts(contexts));
Iterable<PermissionHolder> traversal = graph.traverse(TraversalAlgorithm.DEPTH_FIRST_PRE_ORDER, this.parent);
ImmutableList.Builder<LPSubjectReference> subjects = ImmutableList.builder();
for (PermissionHolder parent : traversal) {
if (!(parent instanceof Group)) {
continue;
}
subjects.add(((SpongeGroup) parent).sponge().toReference());
}
return subjects.build();
}
use of me.lucko.luckperms.sponge.service.model.LPSubjectReference in project LuckPerms by lucko.
the class CalculatedSubject method resolveAllParents.
public Set<LPSubjectReference> resolveAllParents(ImmutableContextSet filter) {
SubjectInheritanceGraph graph = SubjectInheritanceGraphs.getGraph(filter);
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(filter)) {
if (!result.contains(entry)) {
result.add(entry);
}
}
}
return result;
}
Aggregations