mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 03:57:36 +01:00
parent
31e436868d
commit
9c92522564
@ -329,6 +329,10 @@ data:
|
||||
# collections for different servers. The default is no prefix.
|
||||
mongodb_collection_prefix: ''
|
||||
|
||||
# MongoDB ClientConnectionURI for use with replicasets and custom connection options
|
||||
# See https://docs.mongodb.com/manual/reference/connection-string/
|
||||
mongodb_connection_URI: ''
|
||||
|
||||
# This option controls how frequently LuckPerms will perform a sync task.
|
||||
# A sync task will refresh all data from the storage, and ensure that the most up-to-date data is
|
||||
# being used by the plugin.
|
||||
|
@ -271,6 +271,10 @@ data:
|
||||
# collections for different servers. The default is no prefix.
|
||||
mongodb_collection_prefix: ''
|
||||
|
||||
# MongoDB ClientConnectionURI for use with replicasets and custom connection options
|
||||
# See https://docs.mongodb.com/manual/reference/connection-string/
|
||||
mongodb_connection_URI: ''
|
||||
|
||||
# This option controls how frequently LuckPerms will perform a sync task.
|
||||
# A sync task will refresh all data from the storage, and ensure that the most up-to-date data is
|
||||
# being used by the plugin.
|
||||
|
@ -405,6 +405,11 @@ public class ConfigKeys {
|
||||
*/
|
||||
public static final ConfigKey<String> MONGODB_COLLECTION_PREFIX = EnduringKey.wrap(StringKey.of("data.mongodb_collection_prefix", ""));
|
||||
|
||||
/**
|
||||
* MongoDB ClientConnectionURI to override default connection options
|
||||
*/
|
||||
public static final ConfigKey<String> MONGODB_CONNECTION_URI = EnduringKey.wrap(StringKey.of("data.mongodb_connection_URI", ""));
|
||||
|
||||
/**
|
||||
* The name of the storage method being used
|
||||
*/
|
||||
|
@ -158,7 +158,8 @@ public class StorageFactory {
|
||||
return new MongoDao(
|
||||
this.plugin,
|
||||
this.plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES),
|
||||
this.plugin.getConfiguration().get(ConfigKeys.MONGODB_COLLECTION_PREFIX)
|
||||
this.plugin.getConfiguration().get(ConfigKeys.MONGODB_COLLECTION_PREFIX),
|
||||
this.plugin.getConfiguration().get(ConfigKeys.MONGODB_CONNECTION_URI)
|
||||
);
|
||||
case YAML:
|
||||
return new YamlDao(this.plugin, "yaml-storage");
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.storage.dao.mongodb;
|
||||
import com.google.common.base.Strings;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoClientURI;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
@ -77,15 +78,20 @@ public class MongoDao extends AbstractDao {
|
||||
private MongoClient mongoClient;
|
||||
private MongoDatabase database;
|
||||
private final String prefix;
|
||||
private final String connectionURI;
|
||||
|
||||
public MongoDao(LuckPermsPlugin plugin, StorageCredentials configuration, String prefix) {
|
||||
public MongoDao(LuckPermsPlugin plugin, StorageCredentials configuration, String prefix, String connectionURI) {
|
||||
super(plugin, "MongoDB");
|
||||
this.configuration = configuration;
|
||||
this.prefix = prefix;
|
||||
this.connectionURI = connectionURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!Strings.isNullOrempty(this.connectionURI)) {
|
||||
this.mongoClient = new MongoClient(new MongoClientURI(this.connectionURI));
|
||||
} else {
|
||||
MongoCredential credential = null;
|
||||
if (!Strings.isNullOrEmpty(this.configuration.getUsername())) {
|
||||
credential = MongoCredential.createCredential(
|
||||
@ -105,6 +111,7 @@ public class MongoDao extends AbstractDao {
|
||||
} else {
|
||||
this.mongoClient = new MongoClient(address, credential, MongoClientOptions.builder().build());
|
||||
}
|
||||
}
|
||||
|
||||
this.database = this.mongoClient.getDatabase(this.configuration.getDatabase());
|
||||
}
|
||||
|
@ -329,6 +329,10 @@ data:
|
||||
# collections for different servers. The default is no prefix.
|
||||
mongodb_collection_prefix: ''
|
||||
|
||||
# MongoDB ClientConnectionURI for use with replicasets and custom connection options
|
||||
# See https://docs.mongodb.com/manual/reference/connection-string/
|
||||
mongodb_connection_URI: ''
|
||||
|
||||
# This option controls how frequently LuckPerms will perform a sync task.
|
||||
# A sync task will refresh all data from the storage, and ensure that the most up-to-date data is
|
||||
# being used by the plugin.
|
||||
|
@ -278,6 +278,10 @@ data {
|
||||
# collections for different servers. The default is no prefix.
|
||||
mongodb_collection_prefix=""
|
||||
|
||||
# MongoDB ClientConnectionURI for use with replicasets and custom connection options
|
||||
# See https://docs.mongodb.com/manual/reference/connection-string/
|
||||
mongodb_connection_URI=""
|
||||
|
||||
# This option controls how frequently LuckPerms will perform a sync task.
|
||||
# A sync task will refresh all data from the storage, and ensure that the most up-to-date data is
|
||||
# being used by the plugin.
|
||||
|
Loading…
Reference in New Issue
Block a user