From 918ea7503a772c70749cc8d9cfb4cfb64b020398 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 13 May 2020 11:19:35 +0100 Subject: [PATCH] Fix bug with duplicated users in editor (lucko/LuckPermsWeb#235) --- .../common/commands/misc/EditorCommand.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 3410f037e..79102142c 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 @@ -49,9 +49,10 @@ import net.luckperms.api.query.QueryOptions; import java.util.ArrayList; import java.util.Comparator; -import java.util.LinkedHashSet; +import java.util.LinkedHashMap; import java.util.List; -import java.util.Set; +import java.util.Map; +import java.util.UUID; public class EditorCommand extends SingleCommand { private static final int MAX_USERS = 1000; @@ -92,23 +93,24 @@ public class EditorCommand extends SingleCommand { } if (type.includingUsers) { // include all online players - Set users = new LinkedHashSet<>(plugin.getUserManager().getAll().values()); + Map users = new LinkedHashMap<>(plugin.getUserManager().getAll()); // then fill up with other users if (type.includingOffline && users.size() < MAX_USERS) { plugin.getStorage().getUniqueUsers().join().stream() + .filter(uuid -> !users.containsKey(uuid)) .sorted() .limit(MAX_USERS - users.size()) .forEach(uuid -> { User user = plugin.getStorage().loadUser(uuid, null).join(); if (user != null) { - holders.add(user); + users.put(uuid, user); } plugin.getUserManager().getHouseKeeper().cleanup(uuid); }); } - users.stream() + users.values().stream() .sorted(Comparator .comparingInt(u -> u.getCachedData().getMetaData(QueryOptions.nonContextual()).getWeight(MetaCheckEvent.Origin.INTERNAL)) .thenComparing(User::getFormattedDisplayName, String.CASE_INSENSITIVE_ORDER)