Fix group listmembers command behaviour with the default group (#2088)

This commit is contained in:
Luck 2020-05-09 19:16:17 +01:00
parent bd9ae9dbd5
commit 3d358e57ff
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 18 additions and 2 deletions

View File

@ -303,7 +303,6 @@ public class CommandManager {
replaceArgs(args, 3, arg -> arg.equals("i") ? "info" : null);
}
}
}
}
}

View File

@ -40,6 +40,8 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
import me.lucko.luckperms.common.locale.message.Message;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.HolderType;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.model.manager.group.GroupManager;
import me.lucko.luckperms.common.node.comparator.NodeEntryComparator;
import me.lucko.luckperms.common.node.factory.NodeCommandFactory;
import me.lucko.luckperms.common.node.matcher.ConstraintNodeMatcher;
@ -80,7 +82,8 @@ public class GroupListMembers extends ChildCommand<Group> {
return CommandResult.NO_PERMISSION;
}
ConstraintNodeMatcher<InheritanceNode> matcher = StandardNodeMatchers.key(Inheritance.builder(group.getName()).build());
InheritanceNode node = Inheritance.builder(group.getName()).build();
ConstraintNodeMatcher<InheritanceNode> matcher = StandardNodeMatchers.key(node);
int page = ArgumentParser.parseIntOrElse(0, args, 1);
Message.SEARCH_SEARCHING_MEMBERS.send(sender, group.getName());
@ -89,6 +92,19 @@ public class GroupListMembers extends ChildCommand<Group> {
.filter(n -> n.getNode().getValue())
.collect(Collectors.toList());
// special handling for default group
if (group.getName().equals(GroupManager.DEFAULT_GROUP_NAME)) {
// include all non-saved online players in the results
for (User user : plugin.getUserManager().getAll().values()) {
if (!plugin.getUserManager().shouldSave(user)) {
matchedUsers.add(NodeEntry.of(user.getUniqueId(), node));
}
}
// send a warning message about this behaviour
Message.SEARCH_RESULT_GROUP_DEFAULT.send(sender);
}
List<NodeEntry<String, InheritanceNode>> matchedGroups = plugin.getStorage().getGroupsWithPermission(matcher).join().stream()
.filter(n -> n.getNode().getValue())
.collect(Collectors.toList());

View File

@ -147,6 +147,7 @@ public enum Message {
SEARCH_SEARCHING("&aSearching for users and groups with &bpermissions {}&a...", true),
SEARCH_SEARCHING_MEMBERS("&aSearching for users and groups who inherit from &b{}&a...", true),
SEARCH_RESULT_GROUP_DEFAULT("&7Note: when searching for members of the default group, offline players with no other permissions will not be shown!", true),
SEARCH_RESULT("&aFound &b{}&a entries from &b{}&a users and &b{}&a groups.", true),
SEARCH_SHOWING_USERS("&bShowing user entries: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)", true),