Set mongodb uuid representation (#3324)

This commit is contained in:
Luck 2022-02-27 13:17:12 +00:00
parent 4bdcca6566
commit 8ed63159ce
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -68,6 +68,7 @@ import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeBuilder;
import org.bson.Document;
import org.bson.UuidRepresentation;
import java.time.Instant;
import java.util.ArrayList;
@ -111,8 +112,11 @@ public class MongoStorage implements StorageImplementation {
@Override
public void init() {
MongoClientOptions.Builder options = MongoClientOptions.builder()
.uuidRepresentation(UuidRepresentation.JAVA_LEGACY);
if (!Strings.isNullOrEmpty(this.connectionUri)) {
this.mongoClient = new MongoClient(new MongoClientURI(this.connectionUri));
this.mongoClient = new MongoClient(new MongoClientURI(this.connectionUri, options));
} else {
MongoCredential credential = null;
if (!Strings.isNullOrEmpty(this.configuration.getUsername())) {
@ -129,9 +133,9 @@ public class MongoStorage implements StorageImplementation {
ServerAddress address = new ServerAddress(host, port);
if (credential == null) {
this.mongoClient = new MongoClient(address);
this.mongoClient = new MongoClient(address, options.build());
} else {
this.mongoClient = new MongoClient(address, credential, MongoClientOptions.builder().build());
this.mongoClient = new MongoClient(address, credential, options.build());
}
}