Move DatabaseSettings Only

This commit is contained in:
MC~蛟龙 2024-07-11 20:50:31 +08:00
parent ea98f7b9f2
commit 18b80db43f
5 changed files with 47 additions and 49 deletions

View File

@ -73,9 +73,6 @@ public final class PluginSettings implements SettingsHolder {
public static final Property<Boolean> FORCE_VAULT_HOOK = public static final Property<Boolean> FORCE_VAULT_HOOK =
newProperty("settings.forceVaultHook", false); newProperty("settings.forceVaultHook", false);
@Comment("The name of the server, used in some placeholders.")
public static final Property<String> SERVER_NAME = newProperty("settings.serverName", "Your Minecraft Server");
private PluginSettings() { private PluginSettings() {
} }

View File

@ -4,4 +4,7 @@ dependencies {
compileOnly(project(":project:module-logger")) compileOnly(project(":project:module-logger"))
compileOnly(project(":project:module-configuration")) compileOnly(project(":project:module-configuration"))
compileOnly(project(":project:module-message")) compileOnly(project(":project:module-message"))
compileOnly(libs.guava)
compileOnly(libs.configme)
compileOnly(libs.jalu.injector)
} }

View File

@ -5,31 +5,29 @@ import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.Property;
import fr.xephi.authme.datasource.DataSourceType; import fr.xephi.authme.datasource.DataSourceType;
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
public final class DatabaseSettings implements SettingsHolder { public final class DatabaseSettings implements SettingsHolder {
@Comment({"What type of database do you want to use?", @Comment({"What type of database do you want to use?",
"Valid values: H2, SQLITE, MARIADB, MYSQL, POSTGRESQL"}) "Valid values: H2, SQLITE, MARIADB, MYSQL, POSTGRESQL"})
public static final Property<DataSourceType> BACKEND = public static final Property<DataSourceType> BACKEND =
newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE); PropertyInitializer.newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE);
@Comment({"Enable the database caching system, should be disabled on bungeecord environments", @Comment({"Enable the database caching system, should be disabled on bungeecord environments",
"or when a website integration is being used."}) "or when a website integration is being used."})
public static final Property<Boolean> USE_CACHING = public static final Property<Boolean> USE_CACHING =
newProperty("DataSource.caching", true); PropertyInitializer.newProperty("DataSource.caching", true);
@Comment("Should we try to use VirtualThreads(Java 21+) for database cache loader?") @Comment("Should we try to use VirtualThreads(Java 21+) for database cache loader?")
public static final Property<Boolean> USE_VIRTUAL_THREADS = public static final Property<Boolean> USE_VIRTUAL_THREADS =
newProperty("DataSource.useVirtualThreadsCache", false); PropertyInitializer.newProperty("DataSource.useVirtualThreadsCache", false);
@Comment("Database host address") @Comment("Database host address")
public static final Property<String> MYSQL_HOST = public static final Property<String> MYSQL_HOST =
newProperty("DataSource.mySQLHost", "127.0.0.1"); PropertyInitializer.newProperty("DataSource.mySQLHost", "127.0.0.1");
@Comment("Database port") @Comment("Database port")
public static final Property<String> MYSQL_PORT = public static final Property<String> MYSQL_PORT =
newProperty("DataSource.mySQLPort", "3306"); PropertyInitializer.newProperty("DataSource.mySQLPort", "3306");
@Comment({"Replacement of Mysql's useSsl (for MariaDB only).", @Comment({"Replacement of Mysql's useSsl (for MariaDB only).",
"- disable: No SSL", "- disable: No SSL",
@ -38,133 +36,133 @@ public final class DatabaseSettings implements SettingsHolder {
"- verify_full: Encryption, certificate validation and hostname validation", "- verify_full: Encryption, certificate validation and hostname validation",
"Read more: https://bit.ly/mariadb-sslmode"}) "Read more: https://bit.ly/mariadb-sslmode"})
public static final Property<String> MARIADB_SSL_MODE = public static final Property<String> MARIADB_SSL_MODE =
newProperty("DataSource.MariaDbSslMode", "disabled"); PropertyInitializer.newProperty("DataSource.MariaDbSslMode", "disabled");
@Comment({"Connect to MySQL database over SSL", @Comment({"Connect to MySQL database over SSL",
"If you're using MariaDB, use sslMode instead"}) "If you're using MariaDB, use sslMode instead"})
public static final Property<Boolean> MYSQL_USE_SSL = public static final Property<Boolean> MYSQL_USE_SSL =
newProperty("DataSource.mySQLUseSSL", true); PropertyInitializer.newProperty("DataSource.mySQLUseSSL", true);
@Comment({"Verification of server's certificate.", @Comment({"Verification of server's certificate.",
"We would not recommend to set this option to false.", "We would not recommend to set this option to false.",
"Set this option to false at your own risk if and only if you know what you're doing"}) "Set this option to false at your own risk if and only if you know what you're doing"})
public static final Property<Boolean> MYSQL_CHECK_SERVER_CERTIFICATE = public static final Property<Boolean> MYSQL_CHECK_SERVER_CERTIFICATE =
newProperty("DataSource.mySQLCheckServerCertificate", true); PropertyInitializer.newProperty("DataSource.mySQLCheckServerCertificate", true);
@Comment({"Authorize client to retrieve RSA server public key.", @Comment({"Authorize client to retrieve RSA server public key.",
"Advanced option, ignore if you don't know what it means.", "Advanced option, ignore if you don't know what it means.",
"If you are using MariaDB, use MariaDbSslMode instead."}) "If you are using MariaDB, use MariaDbSslMode instead."})
public static final Property<Boolean> MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL = public static final Property<Boolean> MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL =
newProperty("DataSource.mySQLAllowPublicKeyRetrieval", true); PropertyInitializer.newProperty("DataSource.mySQLAllowPublicKeyRetrieval", true);
@Comment("Username to connect to the MySQL database") @Comment("Username to connect to the MySQL database")
public static final Property<String> MYSQL_USERNAME = public static final Property<String> MYSQL_USERNAME =
newProperty("DataSource.mySQLUsername", "authme"); PropertyInitializer.newProperty("DataSource.mySQLUsername", "authme");
@Comment("Password to connect to the MySQL database") @Comment("Password to connect to the MySQL database")
public static final Property<String> MYSQL_PASSWORD = public static final Property<String> MYSQL_PASSWORD =
newProperty("DataSource.mySQLPassword", "12345"); PropertyInitializer.newProperty("DataSource.mySQLPassword", "12345");
@Comment("Database Name, use with converters or as SQLITE database name") @Comment("Database Name, use with converters or as SQLITE database name")
public static final Property<String> MYSQL_DATABASE = public static final Property<String> MYSQL_DATABASE =
newProperty("DataSource.mySQLDatabase", "authme"); PropertyInitializer.newProperty("DataSource.mySQLDatabase", "authme");
@Comment("Table of the database") @Comment("Table of the database")
public static final Property<String> MYSQL_TABLE = public static final Property<String> MYSQL_TABLE =
newProperty("DataSource.mySQLTablename", "authme"); PropertyInitializer.newProperty("DataSource.mySQLTablename", "authme");
@Comment("Column of IDs to sort data") @Comment("Column of IDs to sort data")
public static final Property<String> MYSQL_COL_ID = public static final Property<String> MYSQL_COL_ID =
newProperty("DataSource.mySQLColumnId", "id"); PropertyInitializer.newProperty("DataSource.mySQLColumnId", "id");
@Comment("Column for storing or checking players nickname") @Comment("Column for storing or checking players nickname")
public static final Property<String> MYSQL_COL_NAME = public static final Property<String> MYSQL_COL_NAME =
newProperty("DataSource.mySQLColumnName", "username"); PropertyInitializer.newProperty("DataSource.mySQLColumnName", "username");
@Comment("Column for storing or checking players RealName") @Comment("Column for storing or checking players RealName")
public static final Property<String> MYSQL_COL_REALNAME = public static final Property<String> MYSQL_COL_REALNAME =
newProperty("DataSource.mySQLRealName", "realname"); PropertyInitializer.newProperty("DataSource.mySQLRealName", "realname");
@Comment("Column for storing players passwords") @Comment("Column for storing players passwords")
public static final Property<String> MYSQL_COL_PASSWORD = public static final Property<String> MYSQL_COL_PASSWORD =
newProperty("DataSource.mySQLColumnPassword", "password"); PropertyInitializer.newProperty("DataSource.mySQLColumnPassword", "password");
@Comment("Column for storing players passwords salts") @Comment("Column for storing players passwords salts")
public static final Property<String> MYSQL_COL_SALT = public static final Property<String> MYSQL_COL_SALT =
newProperty("DataSource.mySQLColumnSalt", ""); PropertyInitializer.newProperty("DataSource.mySQLColumnSalt", "");
@Comment("Column for storing players emails") @Comment("Column for storing players emails")
public static final Property<String> MYSQL_COL_EMAIL = public static final Property<String> MYSQL_COL_EMAIL =
newProperty("DataSource.mySQLColumnEmail", "email"); PropertyInitializer.newProperty("DataSource.mySQLColumnEmail", "email");
@Comment("Column for storing if a player is logged in or not") @Comment("Column for storing if a player is logged in or not")
public static final Property<String> MYSQL_COL_ISLOGGED = public static final Property<String> MYSQL_COL_ISLOGGED =
newProperty("DataSource.mySQLColumnLogged", "isLogged"); PropertyInitializer.newProperty("DataSource.mySQLColumnLogged", "isLogged");
@Comment("Column for storing if a player has a valid session or not") @Comment("Column for storing if a player has a valid session or not")
public static final Property<String> MYSQL_COL_HASSESSION = public static final Property<String> MYSQL_COL_HASSESSION =
newProperty("DataSource.mySQLColumnHasSession", "hasSession"); PropertyInitializer.newProperty("DataSource.mySQLColumnHasSession", "hasSession");
@Comment("Column for storing a player's TOTP key (for two-factor authentication)") @Comment("Column for storing a player's TOTP key (for two-factor authentication)")
public static final Property<String> MYSQL_COL_TOTP_KEY = public static final Property<String> MYSQL_COL_TOTP_KEY =
newProperty("DataSource.mySQLtotpKey", "totp"); PropertyInitializer.newProperty("DataSource.mySQLtotpKey", "totp");
@Comment("Column for storing the player's last IP") @Comment("Column for storing the player's last IP")
public static final Property<String> MYSQL_COL_LAST_IP = public static final Property<String> MYSQL_COL_LAST_IP =
newProperty("DataSource.mySQLColumnIp", "ip"); PropertyInitializer.newProperty("DataSource.mySQLColumnIp", "ip");
@Comment("Column for storing players lastlogins") @Comment("Column for storing players lastlogins")
public static final Property<String> MYSQL_COL_LASTLOGIN = public static final Property<String> MYSQL_COL_LASTLOGIN =
newProperty("DataSource.mySQLColumnLastLogin", "lastlogin"); PropertyInitializer.newProperty("DataSource.mySQLColumnLastLogin", "lastlogin");
@Comment("Column storing the registration date") @Comment("Column storing the registration date")
public static final Property<String> MYSQL_COL_REGISTER_DATE = public static final Property<String> MYSQL_COL_REGISTER_DATE =
newProperty("DataSource.mySQLColumnRegisterDate", "regdate"); PropertyInitializer.newProperty("DataSource.mySQLColumnRegisterDate", "regdate");
@Comment("Column for storing the IP address at the time of registration") @Comment("Column for storing the IP address at the time of registration")
public static final Property<String> MYSQL_COL_REGISTER_IP = public static final Property<String> MYSQL_COL_REGISTER_IP =
newProperty("DataSource.mySQLColumnRegisterIp", "regip"); PropertyInitializer.newProperty("DataSource.mySQLColumnRegisterIp", "regip");
@Comment("Column for storing player LastLocation - X") @Comment("Column for storing player LastLocation - X")
public static final Property<String> MYSQL_COL_LASTLOC_X = public static final Property<String> MYSQL_COL_LASTLOC_X =
newProperty("DataSource.mySQLlastlocX", "x"); PropertyInitializer.newProperty("DataSource.mySQLlastlocX", "x");
@Comment("Column for storing player LastLocation - Y") @Comment("Column for storing player LastLocation - Y")
public static final Property<String> MYSQL_COL_LASTLOC_Y = public static final Property<String> MYSQL_COL_LASTLOC_Y =
newProperty("DataSource.mySQLlastlocY", "y"); PropertyInitializer.newProperty("DataSource.mySQLlastlocY", "y");
@Comment("Column for storing player LastLocation - Z") @Comment("Column for storing player LastLocation - Z")
public static final Property<String> MYSQL_COL_LASTLOC_Z = public static final Property<String> MYSQL_COL_LASTLOC_Z =
newProperty("DataSource.mySQLlastlocZ", "z"); PropertyInitializer.newProperty("DataSource.mySQLlastlocZ", "z");
@Comment("Column for storing player LastLocation - World Name") @Comment("Column for storing player LastLocation - World Name")
public static final Property<String> MYSQL_COL_LASTLOC_WORLD = public static final Property<String> MYSQL_COL_LASTLOC_WORLD =
newProperty("DataSource.mySQLlastlocWorld", "world"); PropertyInitializer.newProperty("DataSource.mySQLlastlocWorld", "world");
@Comment("Column for storing player LastLocation - Yaw") @Comment("Column for storing player LastLocation - Yaw")
public static final Property<String> MYSQL_COL_LASTLOC_YAW = public static final Property<String> MYSQL_COL_LASTLOC_YAW =
newProperty("DataSource.mySQLlastlocYaw", "yaw"); PropertyInitializer.newProperty("DataSource.mySQLlastlocYaw", "yaw");
@Comment("Column for storing player LastLocation - Pitch") @Comment("Column for storing player LastLocation - Pitch")
public static final Property<String> MYSQL_COL_LASTLOC_PITCH = public static final Property<String> MYSQL_COL_LASTLOC_PITCH =
newProperty("DataSource.mySQLlastlocPitch", "pitch"); PropertyInitializer.newProperty("DataSource.mySQLlastlocPitch", "pitch");
@Comment("Column for storing players uuids (optional)") @Comment("Column for storing players uuids (optional)")
public static final Property<String> MYSQL_COL_PLAYER_UUID = public static final Property<String> MYSQL_COL_PLAYER_UUID =
newProperty("DataSource.mySQLPlayerUUID", ""); PropertyInitializer.newProperty("DataSource.mySQLPlayerUUID", "");
@Comment("Column for storing players groups") @Comment("Column for storing players groups")
public static final Property<String> MYSQL_COL_GROUP = public static final Property<String> MYSQL_COL_GROUP =
newProperty("ExternalBoardOptions.mySQLColumnGroup", ""); PropertyInitializer.newProperty("ExternalBoardOptions.mySQLColumnGroup", "");
@Comment("Overrides the size of the DB Connection Pool, default = 10") @Comment("Overrides the size of the DB Connection Pool, default = 10")
public static final Property<Integer> MYSQL_POOL_SIZE = public static final Property<Integer> MYSQL_POOL_SIZE =
newProperty("DataSource.poolSize", 10); PropertyInitializer.newProperty("DataSource.poolSize", 10);
@Comment({"The maximum lifetime of a connection in the pool, default = 1800 seconds", @Comment({"The maximum lifetime of a connection in the pool, default = 1800 seconds",
"You should set this at least 30 seconds less than mysql server wait_timeout"}) "You should set this at least 30 seconds less than mysql server wait_timeout"})
public static final Property<Integer> MYSQL_CONNECTION_MAX_LIFETIME = public static final Property<Integer> MYSQL_CONNECTION_MAX_LIFETIME =
newProperty("DataSource.maxLifetime", 1800); PropertyInitializer.newProperty("DataSource.maxLifetime", 1800);
private DatabaseSettings() { private DatabaseSettings() {
} }

View File

@ -1,6 +1,7 @@
dependencies { dependencies {
compileOnly(project(":project:module-logger"))
compileOnly(project(":project:module-util")) compileOnly(project(":project:module-util"))
compileOnly(project(":project:module-logger"))
compileOnly(project(":project:module-common"))
compileOnly(project(":project:module-security")) compileOnly(project(":project:module-security"))
compileOnly(libs.configme) compileOnly(libs.configme)
compileOnly(libs.jalu.injector) compileOnly(libs.jalu.injector)

View File

@ -3,5 +3,4 @@ dependencies {
compileOnly(project(":project:module-util")) compileOnly(project(":project:module-util"))
compileOnly(project(":project:module-logger")) compileOnly(project(":project:module-logger"))
compileOnly(project(":project:module-configuration")) compileOnly(project(":project:module-configuration"))
compileOnly(project(":project:module-message"))
} }