From 4ce8ea21f9f823bda6c12610fc1f6af0bf4b2b15 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 10 Nov 2020 15:04:36 +0000 Subject: [PATCH] Sort users with no known username to the bottom of the editor menu --- .../lucko/luckperms/common/commands/misc/EditorCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java index 152bdbb90..982093d3d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java @@ -57,7 +57,7 @@ import java.util.Map; import java.util.UUID; public class EditorCommand extends SingleCommand { - public static final int MAX_USERS = 1000; + public static final int MAX_USERS = 500; public EditorCommand() { super(CommandSpec.EDITOR, "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 2)); @@ -145,7 +145,11 @@ public class EditorCommand extends SingleCommand { users.values().stream() .sorted(Comparator + // sort firstly by the users relative weight (depends on the groups they inherit) .comparingInt(u -> u.getCachedData().getMetaData(QueryOptions.nonContextual()).getWeight(MetaCheckEvent.Origin.INTERNAL)).reversed() + // then, prioritise users we actually have a username for + .thenComparing(u -> u.getUsername().isPresent(), ((Comparator) Boolean::compare).reversed()) + // then sort according to their username .thenComparing(User::getPlainDisplayName, String.CASE_INSENSITIVE_ORDER) ) .forEach(holders::add);