From 5a928d91f4bf8b4bacc8fb8d18fe0474525d78bc Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:35:47 +0100 Subject: [PATCH] MOre documentation --- .../simpleauth/storage/AuthConfig.java | 39 +++++++++++++++---- .../simpleauth/storage/database/MongoDB.java | 15 ------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java index 683b1ee..14c91e3 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java @@ -106,21 +106,47 @@ public class AuthConfig { /** * Whether to use MongoDB instead of LevelDB. - * Note: you need to install MongoDB yourself. + * Note: you need to install MongoDB yourself, as well + * as create a user (account) that will be used by SimpleAuth + * to manage its database. */ public boolean useMongoDB = false; + /** + * Credentials for MongoDB database. + * Leave this as-is if you are using LevelDB. + */ public static class MongoDBCredentials { /** - * Credentials for MongoDB database. - * Leave this as-is if you are using LevelDB. + * Username for the database access. */ public String username = ""; + /** + * Password for the database access. + */ public String password = ""; - public String host = "localhost"; - public int port = 27017; - public String simpleAuthDatabase = "SimpleAuthPlayerData"; + /** + * Database where user with provided credentials + * is located. + */ public String userSourceDatabase = ""; + /** + * Database host (address). + */ + public String host = "localhost"; + /** + * Database port. + * Default: 27017 + */ + public int port = 27017; + /** + * Name of the new database in which SimpleAuth should + * store player data. + */ + public String simpleAuthDatabase = "SimpleAuthPlayerData"; + /** + * Whether to use ssl connection. + */ public boolean useSsl = true; } @@ -153,7 +179,6 @@ public class AuthConfig { public String disallowedUsername = "§6Invalid username characters! Allowed character regex: %s"; public String playerAlreadyOnline = "§cPlayer %s is already online!"; public String worldSpawnSet = "§aSpawn for logging in was set successfully."; - public String corruptedPlayerData = "§cYour data is probably corrupted. Please contact admin."; public String userNotRegistered = "§cThis player is not registered!"; public String cannotLogout = "§cYou cannot logout!"; } diff --git a/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java b/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java index 98398e2..e93243b 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java @@ -22,20 +22,6 @@ public class MongoDB { private static MongoClient mongoClient; public static void initialize() { - - /*MongoCredential credential = MongoCredential.createCredential( - config.mongoDBCredentials.username, - config.mongoDBCredentials.userSourceDatabase, - config.mongoDBCredentials.password.toCharArray() - ); - - mongoClient = MongoClients.create( - MongoClientSettings.builder() - .applyToClusterSettings(builder -> - builder.hosts(Collections.singletonList(new ServerAddress(config.mongoDBCredentials.host, config.mongoDBCredentials.port)))) - .applyToSslSettings(builder -> builder.enabled(config.mongoDBCredentials.useSsl)) - .credential(credential) - .build());*/ mongoClient = MongoClients.create( String.format( "mongodb://%s:%s@%s:%d/?authSource=%s&useSsl=%b", @@ -47,7 +33,6 @@ public class MongoDB { config.mongoDBCredentials.useSsl ) ); - //mongoClient = MongoClients.create(String.format("mongodb://%s:%d", config.mongoDBCredentials.host, config.mongoDBCredentials.port)); MongoDatabase database = mongoClient.getDatabase(config.mongoDBCredentials.simpleAuthDatabase); collection = database.getCollection("players"); }