Submit users/groups to the editor in weight order

This commit is contained in:
Luck 2018-03-01 18:26:32 +00:00
parent 6c0bb61cb1
commit cd5447de38
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -74,10 +74,17 @@ public class EditorCommand extends SingleCommand {
// collect holders // collect holders
List<PermissionHolder> holders = new ArrayList<>(); List<PermissionHolder> holders = new ArrayList<>();
if (type.includingGroups) { if (type.includingGroups) {
holders.addAll(plugin.getGroupManager().getAll().values()); plugin.getGroupManager().getAll().values().stream()
.sorted((o1, o2) -> {
int i = Integer.compare(o2.getWeight().orElse(0), o1.getWeight().orElse(0));
return i != 0 ? i : o1.getName().compareToIgnoreCase(o2.getName());
})
.forEach(holders::add);
} }
if (type.includingUsers) { if (type.includingUsers) {
holders.addAll(plugin.getUserManager().getAll().values()); plugin.getUserManager().getAll().values().stream()
.sorted((o1, o2) -> o1.getFriendlyName().compareToIgnoreCase(o2.getFriendlyName()))
.forEach(holders::add);
} }
// remove holders which the sender doesn't have perms to view // remove holders which the sender doesn't have perms to view