mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-23 19:16:37 +01:00
Fix NodeMap#size method and rename some things
This commit is contained in:
parent
cc08390abe
commit
d12d13d6ea
@ -67,7 +67,7 @@ public class GroupSetDisplayName extends ChildCommand<Group> {
|
||||
String name = args.get(0);
|
||||
ImmutableContextSet context = args.getContextOrDefault(1, plugin).immutableCopy();
|
||||
|
||||
String previousName = target.normalData().nodesSetInContext(context).stream()
|
||||
String previousName = target.normalData().nodesInContext(context).stream()
|
||||
.filter(NodeType.DISPLAY_NAME::matches)
|
||||
.map(NodeType.DISPLAY_NAME::cast)
|
||||
.findFirst()
|
||||
|
@ -59,7 +59,7 @@ public class LogNotify extends ChildCommand<Log> {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<? extends Node> node = user.normalData().nodesSetInContext(ImmutableContextSetImpl.EMPTY).stream()
|
||||
Optional<? extends Node> node = user.normalData().nodesInContext(ImmutableContextSetImpl.EMPTY).stream()
|
||||
.filter(n -> n.getKey().equalsIgnoreCase(IGNORE_NODE))
|
||||
.findFirst();
|
||||
|
||||
|
@ -108,7 +108,11 @@ public final class NodeMap {
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.map.size();
|
||||
int size = 0;
|
||||
for (SortedSet<Node> values : this.map.values()) {
|
||||
size += values.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public List<Node> asList() {
|
||||
@ -290,7 +294,7 @@ public final class NodeMap {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Node> nodesSetInContext(ContextSet context) {
|
||||
public Collection<Node> nodesInContext(ContextSet context) {
|
||||
final SortedSet<Node> values = this.map.get(context.immutableCopy());
|
||||
if (values == null) {
|
||||
return ImmutableSet.of();
|
||||
@ -298,7 +302,7 @@ public final class NodeMap {
|
||||
return new ArrayList<>(values);
|
||||
}
|
||||
|
||||
public Collection<InheritanceNode> inheritanceNodesSetInContext(ContextSet context) {
|
||||
public Collection<InheritanceNode> inheritanceNodesInContext(ContextSet context) {
|
||||
final SortedSet<InheritanceNode> values = this.inheritanceMap.get(context.immutableCopy());
|
||||
if (values == null) {
|
||||
return ImmutableSet.of();
|
||||
|
@ -275,7 +275,7 @@ public final class Track {
|
||||
}
|
||||
|
||||
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
||||
List<InheritanceNode> nodes = user.normalData().inheritanceNodesSetInContext(context).stream()
|
||||
List<InheritanceNode> nodes = user.normalData().inheritanceNodesInContext(context).stream()
|
||||
.filter(Node::getValue)
|
||||
.filter(node -> containsGroup(node.getGroupName()))
|
||||
.distinct()
|
||||
@ -340,7 +340,7 @@ public final class Track {
|
||||
}
|
||||
|
||||
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
||||
List<InheritanceNode> nodes = user.normalData().inheritanceNodesSetInContext(context).stream()
|
||||
List<InheritanceNode> nodes = user.normalData().inheritanceNodesInContext(context).stream()
|
||||
.filter(Node::getValue)
|
||||
.filter(node -> containsGroup(node.getGroupName()))
|
||||
.distinct()
|
||||
|
@ -82,7 +82,7 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
||||
public boolean giveDefaultIfNeeded(User user, boolean save) {
|
||||
boolean work = false;
|
||||
|
||||
Collection<InheritanceNode> globalGroups = user.normalData().inheritanceNodesSetInContext(ImmutableContextSetImpl.EMPTY);
|
||||
Collection<InheritanceNode> globalGroups = user.normalData().inheritanceNodesInContext(ImmutableContextSetImpl.EMPTY);
|
||||
|
||||
// check that they are actually a member of their primary group, otherwise remove it
|
||||
if (this.plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION_METHOD).equals("stored")) {
|
||||
|
@ -111,7 +111,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
@Override
|
||||
public ImmutableMap<String, Boolean> getPermissions(ImmutableContextSet contexts) {
|
||||
ImmutableMap.Builder<String, Boolean> builder = ImmutableMap.builder();
|
||||
for (Node n : this.holder.getData(this.type).nodesSetInContext(contexts)) {
|
||||
for (Node n : this.holder.getData(this.type).nodesInContext(contexts)) {
|
||||
builder.put(n.getKey(), n.getValue());
|
||||
}
|
||||
return builder.build();
|
||||
@ -172,7 +172,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
@Override
|
||||
public ImmutableList<LPSubjectReference> getParents(ImmutableContextSet contexts) {
|
||||
ImmutableList.Builder<LPSubjectReference> builder = ImmutableList.builder();
|
||||
for (InheritanceNode n : this.holder.getData(this.type).inheritanceNodesSetInContext(contexts)) {
|
||||
for (InheritanceNode n : this.holder.getData(this.type).inheritanceNodesInContext(contexts)) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(n.getGroupName()).join().toReference());
|
||||
}
|
||||
return builder.build();
|
||||
@ -249,7 +249,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
|
||||
@Override
|
||||
public ImmutableMap<String, String> getOptions(ImmutableContextSet contexts) {
|
||||
return nodesToOptions(this.holder.getData(this.type).nodesSetInContext(contexts));
|
||||
return nodesToOptions(this.holder.getData(this.type).nodesInContext(contexts));
|
||||
}
|
||||
|
||||
private static ImmutableMap<String, String> nodesToOptions(Iterable<? extends Node> nodes) {
|
||||
|
Loading…
Reference in New Issue
Block a user