This commit is contained in:
MC~蛟龙 2024-07-11 21:56:54 +08:00
parent db1535d75e
commit 4396e1b60c
4 changed files with 55 additions and 48 deletions

View File

@ -21,17 +21,21 @@ subprojects {
dependencies { dependencies {
// Modules // Modules
implementation(project(":project:module-configuration", "shadow")) implementation(project(":project:module-configuration"))
implementation(project(":project:module-logger", "shadow")) implementation(project(":project:module-logger"))
implementation(project(":project:module-util", "shadow")) implementation(project(":project:module-util"))
implementation(project(":project:module-security", "shadow")) implementation(project(":project:module-security"))
implementation(project(":project:module-common", "shadow")) implementation(project(":project:module-common"))
implementation(project(":project:module-message", "shadow")) implementation(project(":project:module-message"))
implementation(project(":project:module-database", "shadow")) implementation(project(":project:module-database"))
implementation(project(":project:module-mail", "shadow")) implementation(project(":project:module-mail"))
// Adventure API // Adventure API
implementation(rootProject.libs.adventure.text.minimessage) implementation(rootProject.libs.adventure.text.minimessage)
implementation(rootProject.libs.adventure.text.serializer.gson) implementation(rootProject.libs.adventure.text.serializer.gson)
// ConfigMe
implementation(rootProject.libs.configme) {
exclude("org.yaml", "snakeyaml")
}
// Spigot API, https://www.spigotmc.org/ // Spigot API, https://www.spigotmc.org/
compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
// Java Libraries // Java Libraries
@ -45,14 +49,8 @@ subprojects {
} }
// Library for tar archives // Library for tar archives
implementation("javatar:javatar:2.5") implementation("javatar:javatar:2.5")
// Log4J Logger (required by the console filter) TODO Remove
compileOnly("org.apache.logging.log4j:log4j-core:2.20.0") // Log4J version bundled in 1.12.2
// Libby // Libby
implementation("com.alessiodp.libby:libby-bukkit:2.0.0-SNAPSHOT") implementation("com.alessiodp.libby:libby-bukkit:2.0.0-SNAPSHOT")
// Database Connection Pool TODO Remove
implementation("com.zaxxer:HikariCP:4.0.3" /* Latest java 8 release */) {
exclude("org.slf4j", "slf4j-api")
}
// HikariCP Logger // HikariCP Logger
implementation("org.slf4j:slf4j-simple:1.7.36") // We can't update to 2.x as long as we use HikariCP for java 8 implementation("org.slf4j:slf4j-simple:1.7.36") // We can't update to 2.x as long as we use HikariCP for java 8
// MySQL connector, shaded into the legacy jar // MySQL connector, shaded into the legacy jar
@ -65,10 +63,6 @@ subprojects {
exclude("org.checkerframework", "checker-qual") exclude("org.checkerframework", "checker-qual")
} }
implementation("com.google.code.gson:gson:2.10.1") implementation("com.google.code.gson:gson:2.10.1")
// ConfigMe
implementation("ch.jalu:configme:1.3.1") {
exclude("org.yaml", "snakeyaml")
}
// Dependencies used by HAProxy feature // Dependencies used by HAProxy feature
// implementation("io.netty:netty-codec-haproxy:4.1.104.Final") // implementation("io.netty:netty-codec-haproxy:4.1.104.Final")
// compileOnly("commons-validator:commons-validator:1.8.0") // compileOnly("commons-validator:commons-validator:1.8.0")
@ -84,7 +78,6 @@ subprojects {
compileOnly("net.essentialsx:EssentialsX:2.20.1") compileOnly("net.essentialsx:EssentialsX:2.20.1")
// XAuth, another authentication plugin, required by the database converter // XAuth, another authentication plugin, required by the database converter
compileOnly("de.luricos.bukkit:xAuth:2.6.1-SNAPSHOT") compileOnly("de.luricos.bukkit:xAuth:2.6.1-SNAPSHOT")
implementation("ch.jalu:datasourcecolumns:0.1.1-SNAPSHOT") // TODO REMOVE
implementation("org.postgresql:postgresql:42.7.3") { implementation("org.postgresql:postgresql:42.7.3") {
exclude("org.checkerframework", "checker-qual") exclude("org.checkerframework", "checker-qual")
} }
@ -139,15 +132,28 @@ subprojects {
// bStats metrics class // bStats metrics class
relocate("org.bstats", "${project.group}.libs.org.bstats") relocate("org.bstats", "${project.group}.libs.org.bstats")
relocate("org.mariadb.jdbc", "${project.group}.libs.org.mariadb.jdbc") relocate("org.mariadb.jdbc", "${project.group}.libs.org.mariadb.jdbc")
relocate( relocate("com.github.Anon8281.universalScheduler", "${project.group}.libs.com.github.Anon8281.universalScheduler")
"com.github.Anon8281.universalScheduler",
"${project.group}.libs.com.github.Anon8281.universalScheduler"
)
relocate("com.mysql", "${project.group}.libs.com.mysql") relocate("com.mysql", "${project.group}.libs.com.mysql")
relocate("com.google.protobuf", "${project.group}.libs.com.google.protobuf") relocate("com.google.protobuf", "${project.group}.libs.com.google.protobuf")
relocate("io.netty", "${project.group}.libs.io.netty") relocate("io.netty", "${project.group}.libs.io.netty")
relocate("org.apache.commons.validator", "${project.group}.libs.org.apache.commons.validator") relocate("org.apache.commons.validator", "${project.group}.libs.org.apache.commons.validator")
relocate("com.alessiodp.libby", "${project.group}.libs.com.alessiodp.libby") relocate("com.alessiodp.libby", "${project.group}.libs.com.alessiodp.libby")
// Module-Configuration:
// NightConfig
relocate("com.electronwill.nightconfig", "com.electronwill.nightconfig_3_6_7")
// Snakeyaml
relocate("org.yaml.snakeyaml", "org.yaml.snakeyaml_2_2")
// Module-Util:
relocate("net.ricecode.similarity", "${project.group}.libs.net.ricecode.similarity")
// Module-Security:
relocate("de.rtner", "${project.group}.libs.de.rtner")
relocate("at.favre.lib", "${project.group}.libs.at.favre.lib")
relocate("de.mkammerer", "${project.group}.libs.de.mkammerer")
// Module-Mail:
relocate("org.apache.commons", "${project.group}.libs.org.apache.commons")
// Module-Database:
relocate("com.zaxxer.hikari", "${project.group}.libs.com.zaxxer.hikari")
relocate("ch.jalu", "${project.group}.libs.ch.jalu")
} }
} }

View File

@ -2,13 +2,13 @@ package fr.xephi.authme.command.executable.authme;
import ch.jalu.injector.factory.SingletonStore; import ch.jalu.injector.factory.SingletonStore;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.logger.ConsoleLogger;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.logger.ConsoleLogger;
import fr.xephi.authme.logger.ConsoleLoggerFactory; import fr.xephi.authme.logger.ConsoleLoggerFactory;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SettingsWarner; import fr.xephi.authme.settings.SettingsWarner;
@ -51,7 +51,7 @@ public class ReloadCommand implements ExecutableCommand {
public void executeCommand(CommandSender sender, List<String> arguments) { public void executeCommand(CommandSender sender, List<String> arguments) {
try { try {
settings.reload(); settings.reload();
ConsoleLoggerFactory.reloadSettings(settings); ConsoleLogger.initialize();
settingsWarner.logWarningsForMisconfigurations(); settingsWarner.logWarningsForMisconfigurations();
// We do not change database type for consistency issues, but we'll output a note in the logs // We do not change database type for consistency issues, but we'll output a note in the logs
@ -69,9 +69,9 @@ public class ReloadCommand implements ExecutableCommand {
private void performReloadOnServices() { private void performReloadOnServices() {
reloadableStore.retrieveAllOfType() reloadableStore.retrieveAllOfType()
.forEach(r -> r.reload()); .forEach(r -> r.reload());
settingsDependentStore.retrieveAllOfType() settingsDependentStore.retrieveAllOfType()
.forEach(s -> s.reload(settings)); .forEach(s -> s.reload(settings));
} }
} }

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.service; package fr.xephi.authme.service;
import fr.xephi.authme.logger.ConsoleLogger;
import fr.xephi.authme.datasource.DataSourceType; import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.mail.EmailService; import fr.xephi.authme.logger.ConsoleLogger;
import fr.xephi.authme.logger.ConsoleLoggerFactory; import fr.xephi.authme.logger.ConsoleLoggerFactory;
import fr.xephi.authme.mail.EmailService;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.BackupSettings; import fr.xephi.authme.settings.properties.BackupSettings;
import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.DatabaseSettings;
@ -39,7 +39,7 @@ public class BackupService {
* Constructor. * Constructor.
* *
* @param dataFolder the data folder * @param dataFolder the data folder
* @param settings the plugin settings * @param settings the plugin settings
*/ */
@Inject @Inject
public BackupService(@DataFolder File dataFolder, Settings settings) { public BackupService(@DataFolder File dataFolder, Settings settings) {
@ -60,7 +60,7 @@ public class BackupService {
/** /**
* Performs a backup for the given reason. * Performs a backup for the given reason.
* *
* @param cause backup reason * @param cause backup reason
* @param sender the command sender (nullable) * @param sender the command sender (nullable)
*/ */
public void doBackup(BackupCause cause, CommandSender sender) { public void doBackup(BackupCause cause, CommandSender sender) {
@ -68,7 +68,7 @@ public class BackupService {
// Print a warning if the backup was requested via command or by another plugin // Print a warning if the backup was requested via command or by another plugin
if (cause == BackupCause.COMMAND || cause == BackupCause.OTHER) { if (cause == BackupCause.COMMAND || cause == BackupCause.OTHER) {
logAndSendWarning(sender, logAndSendWarning(sender,
"Can't perform a backup: disabled in configuration. Cause of the backup: " + cause.name()); "Can't perform a backup: disabled in configuration. Cause of the backup: " + cause.name());
} }
return; return;
} else if (BackupCause.START == cause && !settings.getProperty(BackupSettings.ON_SERVER_START) } else if (BackupCause.START == cause && !settings.getProperty(BackupSettings.ON_SERVER_START)
@ -80,7 +80,7 @@ public class BackupService {
// Do backup and check return value! // Do backup and check return value!
if (doBackup()) { if (doBackup()) {
logAndSendMessage(sender, logAndSendMessage(sender,
"A backup has been performed successfully. Cause of the backup: " + cause.name()); "A backup has been performed successfully. Cause of the backup: " + cause.name());
} else { } else {
logAndSendWarning(sender, "Error while performing a backup! Cause of the backup: " + cause.name()); logAndSendWarning(sender, "Error while performing a backup! Cause of the backup: " + cause.name());
} }
@ -116,8 +116,8 @@ public class BackupService {
String backupWindowsPath = settings.getProperty(BackupSettings.MYSQL_WINDOWS_PATH); String backupWindowsPath = settings.getProperty(BackupSettings.MYSQL_WINDOWS_PATH);
boolean isUsingWindows = useWindowsCommand(backupWindowsPath); boolean isUsingWindows = useWindowsCommand(backupWindowsPath);
String backupCommand = isUsingWindows String backupCommand = isUsingWindows
? backupWindowsPath + "\\bin\\mysqldump.exe" + buildMysqlDumpArguments(sqlBackupFile) ? backupWindowsPath + "\\bin\\mysqldump.exe" + buildMysqlDumpArguments(sqlBackupFile)
: "mysqldump" + buildMysqlDumpArguments(sqlBackupFile); : "mysqldump" + buildMysqlDumpArguments(sqlBackupFile);
try { try {
Process runtimeProcess = Runtime.getRuntime().exec(backupCommand); Process runtimeProcess = Runtime.getRuntime().exec(backupCommand);
@ -176,11 +176,11 @@ public class BackupService {
private String buildMysqlDumpArguments(File sqlBackupFile) { private String buildMysqlDumpArguments(File sqlBackupFile) {
String dbUsername = settings.getProperty(DatabaseSettings.MYSQL_USERNAME); String dbUsername = settings.getProperty(DatabaseSettings.MYSQL_USERNAME);
String dbPassword = settings.getProperty(DatabaseSettings.MYSQL_PASSWORD); String dbPassword = settings.getProperty(DatabaseSettings.MYSQL_PASSWORD);
String dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); String dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE); String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
return " -u " + dbUsername + " -p" + dbPassword + " " + dbName return " -u " + dbUsername + " -p" + dbPassword + " " + dbName
+ " --tables " + tableName + " -r " + sqlBackupFile.getPath() + ".sql"; + " --tables " + tableName + " -r " + sqlBackupFile.getPath() + ".sql";
} }
/** /**

View File

@ -148,14 +148,15 @@ public class SendMailSsl {
} }
private static @NotNull Properties getProperties(HtmlEmail email, String oAuth2Token) throws EmailException { private static @NotNull Properties getProperties(HtmlEmail email, String oAuth2Token) throws EmailException {
Properties mailProperties = email.getMailSession().getProperties(); Properties p = email.getMailSession().getProperties();
mailProperties.setProperty("mail.smtp.ssl.enable", "true"); p.setProperty("mail.smtp.ssl.enable", "true");
mailProperties.setProperty("mail.smtp.auth.mechanisms", "XOAUTH2"); p.setProperty("mail.smtp.auth.mechanisms", "XOAUTH2");
mailProperties.setProperty("mail.smtp.sasl.enable", "true"); p.setProperty("mail.smtp.sasl.enable", "true");
mailProperties.setProperty("mail.smtp.sasl.mechanisms", "XOAUTH2"); p.setProperty("mail.smtp.sasl.mechanisms", "XOAUTH2");
mailProperties.setProperty("mail.smtp.auth.login.disable", "true"); p.setProperty("mail.smtp.auth.login.disable", "true");
mailProperties.setProperty("mail.smtp.auth.plain.disable", "true"); p.setProperty("mail.smtp.auth.plain.disable", "true");
mailProperties.setProperty(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oAuth2Token); p.setProperty(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oAuth2Token);
return mailProperties; return p;
} }
} }