mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-19 14:51:38 +01:00
Fix bug with duplicated users in editor (lucko/LuckPermsWeb#235)
This commit is contained in:
parent
dbe07827bd
commit
918ea7503a
@ -49,9 +49,10 @@ import net.luckperms.api.query.QueryOptions;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class EditorCommand extends SingleCommand {
|
public class EditorCommand extends SingleCommand {
|
||||||
private static final int MAX_USERS = 1000;
|
private static final int MAX_USERS = 1000;
|
||||||
@ -92,23 +93,24 @@ public class EditorCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
if (type.includingUsers) {
|
if (type.includingUsers) {
|
||||||
// include all online players
|
// include all online players
|
||||||
Set<User> users = new LinkedHashSet<>(plugin.getUserManager().getAll().values());
|
Map<UUID, User> users = new LinkedHashMap<>(plugin.getUserManager().getAll());
|
||||||
|
|
||||||
// then fill up with other users
|
// then fill up with other users
|
||||||
if (type.includingOffline && users.size() < MAX_USERS) {
|
if (type.includingOffline && users.size() < MAX_USERS) {
|
||||||
plugin.getStorage().getUniqueUsers().join().stream()
|
plugin.getStorage().getUniqueUsers().join().stream()
|
||||||
|
.filter(uuid -> !users.containsKey(uuid))
|
||||||
.sorted()
|
.sorted()
|
||||||
.limit(MAX_USERS - users.size())
|
.limit(MAX_USERS - users.size())
|
||||||
.forEach(uuid -> {
|
.forEach(uuid -> {
|
||||||
User user = plugin.getStorage().loadUser(uuid, null).join();
|
User user = plugin.getStorage().loadUser(uuid, null).join();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
holders.add(user);
|
users.put(uuid, user);
|
||||||
}
|
}
|
||||||
plugin.getUserManager().getHouseKeeper().cleanup(uuid);
|
plugin.getUserManager().getHouseKeeper().cleanup(uuid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
users.stream()
|
users.values().stream()
|
||||||
.sorted(Comparator
|
.sorted(Comparator
|
||||||
.<User>comparingInt(u -> u.getCachedData().getMetaData(QueryOptions.nonContextual()).getWeight(MetaCheckEvent.Origin.INTERNAL))
|
.<User>comparingInt(u -> u.getCachedData().getMetaData(QueryOptions.nonContextual()).getWeight(MetaCheckEvent.Origin.INTERNAL))
|
||||||
.thenComparing(User::getFormattedDisplayName, String.CASE_INSENSITIVE_ORDER)
|
.thenComparing(User::getFormattedDisplayName, String.CASE_INSENSITIVE_ORDER)
|
||||||
|
Loading…
Reference in New Issue
Block a user