mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-16 21:31:35 +01:00
Make getUniqueUsers more resilient to invalid uuids
This commit is contained in:
parent
ea5a05d770
commit
1ca1bcf1d1
@ -32,6 +32,7 @@ import me.lucko.luckperms.common.storage.implementation.file.loader.ConfigurateL
|
|||||||
import me.lucko.luckperms.common.storage.implementation.file.watcher.FileWatcher;
|
import me.lucko.luckperms.common.storage.implementation.file.watcher.FileWatcher;
|
||||||
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
||||||
import me.lucko.luckperms.common.util.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
|
import me.lucko.luckperms.common.util.Uuids;
|
||||||
|
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@ -256,7 +258,8 @@ public class CombinedConfigurateStorage extends AbstractConfigurateStorage {
|
|||||||
public Set<UUID> getUniqueUsers() throws IOException {
|
public Set<UUID> getUniqueUsers() throws IOException {
|
||||||
return this.usersLoader.getNode().getChildrenMap().keySet().stream()
|
return this.usersLoader.getNode().getChildrenMap().keySet().stream()
|
||||||
.map(Object::toString)
|
.map(Object::toString)
|
||||||
.map(UUID::fromString)
|
.map(Uuids::fromString)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -248,7 +249,8 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage {
|
|||||||
return stream.filter(getFileTypeFilter())
|
return stream.filter(getFileTypeFilter())
|
||||||
.map(p -> p.getFileName().toString())
|
.map(p -> p.getFileName().toString())
|
||||||
.map(s -> s.substring(0, s.length() - this.fileExtension.length()))
|
.map(s -> s.substring(0, s.length() - this.fileExtension.length()))
|
||||||
.map(UUID::fromString)
|
.map(Uuids::fromString)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,11 @@ public class MongoStorage implements StorageImplementation {
|
|||||||
MongoCollection<Document> c = this.database.getCollection(this.prefix + "users");
|
MongoCollection<Document> c = this.database.getCollection(this.prefix + "users");
|
||||||
try (MongoCursor<Document> cursor = c.find().iterator()) {
|
try (MongoCursor<Document> cursor = c.find().iterator()) {
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
uuids.add(getDocumentId(cursor.next()));
|
try {
|
||||||
|
uuids.add(getDocumentId(cursor.next()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uuids;
|
return uuids;
|
||||||
|
@ -43,6 +43,7 @@ import me.lucko.luckperms.common.storage.implementation.StorageImplementation;
|
|||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
||||||
import me.lucko.luckperms.common.storage.misc.PlayerSaveResultImpl;
|
import me.lucko.luckperms.common.storage.misc.PlayerSaveResultImpl;
|
||||||
|
import me.lucko.luckperms.common.util.Uuids;
|
||||||
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
||||||
|
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
@ -353,8 +354,10 @@ public class SqlStorage implements StorageImplementation {
|
|||||||
try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(USER_PERMISSIONS_SELECT_DISTINCT))) {
|
try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(USER_PERMISSIONS_SELECT_DISTINCT))) {
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String uuid = rs.getString("uuid");
|
UUID uuid = Uuids.fromString(rs.getString("uuid"));
|
||||||
uuids.add(UUID.fromString(uuid));
|
if (uuid != null) {
|
||||||
|
uuids.add(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user