diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 91cf1a27..7b4ae447 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,10 @@ [versions] guava = "33.2.1-jre" +adventure = "4.17.0" +adventure-platform = "4.3.2" [libraries] -guava = { module = "com.google.guava:guava", version.ref = "guava" } \ No newline at end of file +guava = { module = "com.google.guava:guava", version.ref = "guava" } +adventure-text-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } +adventure-text-serializer-gson = { module = "net.kyori:adventure-text-serializer-gson", version.ref = "adventure" } +adventure-platform-bukkit = { module = "net.kyori:adventure-platform-bukkit", version.ref = "adventure-platform" } \ No newline at end of file diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 4bebf517..2d76b63c 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -32,8 +32,6 @@ subprojects { compileOnly("org.geysermc.floodgate:api:2.2.2-SNAPSHOT") // Jalu Injector implementation("ch.jalu:injector:1.0") - // String comparison library. Used for dynamic help system. - implementation("net.ricecode:string-similarity:1.0.0") // MaxMind GEO IP with our modifications to use GSON in replacement of the big Jackson dependency // GSON is already included and therefore it reduces the file size in comparison to the original version implementation("com.maxmind.db:maxmind-db-gson:2.0.3") { @@ -43,7 +41,7 @@ subprojects { implementation("javatar:javatar:2.5") // Java Email Library implementation("org.apache.commons:commons-email:1.6-SNAPSHOT") - // Log4J Logger (required by the console filter) + // 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 implementation("com.alessiodp.libby:libby-bukkit:2.0.0-SNAPSHOT") @@ -77,8 +75,8 @@ subprojects { compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0") // Adventure API implementation("net.kyori:adventure-text-minimessage:4.17.0") - implementation("net.kyori:adventure-platform-bukkit:4.3.2") implementation("net.kyori:adventure-text-serializer-gson:4.17.0") + implementation("net.kyori:adventure-platform-bukkit:4.3.2") // LuckPerms plugin compileOnly("net.luckperms:api:5.4") // PermissionsEx plugin @@ -143,7 +141,6 @@ subprojects { relocate("org.slf4j", "fr.xephi.authme.libs.org.slf4j") relocate("com.maxmind.db", "fr.xephi.authme.libs.com.maxmind.db") relocate("com.ice.tar", "fr.xephi.authme.libs.com.icetar.tar") - relocate("net.ricecode.similarity", "fr.xephi.authme.libs.ricecode.net.ricecode.similarity") relocate("de.rtner", "fr.xephi.authme.libs.de.rtner") relocate("org.picketbox", "fr.xephi.authme.libs.org.picketbox") relocate("org.jboss.crypto", "fr.xephi.authme.libs.org.jboss.crypto") diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SpawnLoader.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SpawnLoader.java index 171a999b..47e9711d 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SpawnLoader.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SpawnLoader.java @@ -36,7 +36,7 @@ public class SpawnLoader implements Reloadable { private final File authMeConfigurationFile; private final Settings settings; private final PluginHookService pluginHookService; - private Configuration authMeConfiguration; + private FileConfiguration authMeConfiguration; private String[] spawnPriority; private Location essentialsSpawn; private Location cmiSpawn; diff --git a/project/module-configuration/src/main/kotlin/fr/xephi/authme/configruation/ConfigSection.kt b/project/module-configuration/src/main/kotlin/fr/xephi/authme/configruation/ConfigSection.kt index 5e022d10..1ab490bb 100644 --- a/project/module-configuration/src/main/kotlin/fr/xephi/authme/configruation/ConfigSection.kt +++ b/project/module-configuration/src/main/kotlin/fr/xephi/authme/configruation/ConfigSection.kt @@ -4,7 +4,7 @@ import com.electronwill.nightconfig.core.CommentedConfig import com.electronwill.nightconfig.core.Config import com.electronwill.nightconfig.core.EnumGetMethod import fr.xephi.authme.util.Coerce -import fr.xephi.authme.util.StringUtil +import fr.xephi.authme.util.StringUtils /** * ConfigSection @@ -87,7 +87,7 @@ open class ConfigSection( value is List<*> -> root.set(path, unwrap(value, this)) value is Collection<*> && value !is List<*> -> set(path, value.toList()) value is ConfigurationSection -> set(path, value.getConfig()) - value is Map<*, *> -> set(path, value.asConfig(this)) + value is Map<*, *> -> set(path, value.toConfig(this)) value is Commented -> { set(path, value.value) setComment(path, value.comment) @@ -294,7 +294,7 @@ open class ConfigSection( return if (this is ConfigSection) root else error("Not supported") } - private fun Map<*, *>.asConfig(parent: ConfigSection): Config { + private fun Map<*, *>.toConfig(parent: ConfigSection): Config { val section = ConfigSection(parent.root.createSubConfig()) forEach { (k, v) -> section[k.toString()] = v } return section.root @@ -326,7 +326,7 @@ open class ConfigSection( value is List<*> -> unwrap(value, parent) value is Collection<*> && value !is List<*> -> value.toList() value is ConfigurationSection -> value.getConfig() - value is Map<*, *> -> value.asConfig(parent) + value is Map<*, *> -> value.toConfig(parent) else -> value } } diff --git a/project/module-logger/build.gradle.kts b/project/module-logger/build.gradle.kts index c89e77cc..fe9e26f7 100644 --- a/project/module-logger/build.gradle.kts +++ b/project/module-logger/build.gradle.kts @@ -1,3 +1,6 @@ dependencies { + compileOnly(project(":project:module-util")) compileOnly(libs.guava) + // Log4J Logger (required by the console filter) + compileOnly("org.apache.logging.log4j:log4j-core:2.20.0") // Log4J version bundled in 1.12.2 } \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/ConsoleFilter.java b/project/module-logger/src/main/java/fr/xephi/authme/output/ConsoleFilter.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/ConsoleFilter.java rename to project/module-logger/src/main/java/fr/xephi/authme/output/ConsoleFilter.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/Log4JFilter.java b/project/module-logger/src/main/java/fr/xephi/authme/output/Log4JFilter.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/Log4JFilter.java rename to project/module-logger/src/main/java/fr/xephi/authme/output/Log4JFilter.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/LogFilterHelper.java b/project/module-logger/src/main/java/fr/xephi/authme/output/LogFilterHelper.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/LogFilterHelper.java rename to project/module-logger/src/main/java/fr/xephi/authme/output/LogFilterHelper.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/LogLevel.java b/project/module-logger/src/main/java/fr/xephi/authme/output/LogLevel.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/output/LogLevel.java rename to project/module-logger/src/main/java/fr/xephi/authme/output/LogLevel.java diff --git a/project/module-util/build.gradle.kts b/project/module-util/build.gradle.kts index c89e77cc..d38fea13 100644 --- a/project/module-util/build.gradle.kts +++ b/project/module-util/build.gradle.kts @@ -1,3 +1,11 @@ dependencies { compileOnly(libs.guava) + // String comparison library. Used for dynamic help system. + implementation("net.ricecode:string-similarity:1.0.0") +} + +tasks { + shadowJar { + relocate("net.ricecode.similarity", "fr.xephi.authme.libs.ricecode.net.ricecode.similarity") + } } \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/AtomicIntervalCounter.java b/project/module-util/src/main/java/fr/xephi/authme/util/AtomicIntervalCounter.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/AtomicIntervalCounter.java rename to project/module-util/src/main/java/fr/xephi/authme/util/AtomicIntervalCounter.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/ExceptionUtils.java b/project/module-util/src/main/java/fr/xephi/authme/util/ExceptionUtils.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/ExceptionUtils.java rename to project/module-util/src/main/java/fr/xephi/authme/util/ExceptionUtils.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/InternetProtocolUtils.java b/project/module-util/src/main/java/fr/xephi/authme/util/InternetProtocolUtils.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/InternetProtocolUtils.java rename to project/module-util/src/main/java/fr/xephi/authme/util/InternetProtocolUtils.java diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/RandomStringUtils.java b/project/module-util/src/main/java/fr/xephi/authme/util/RandomStringUtils.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/RandomStringUtils.java rename to project/module-util/src/main/java/fr/xephi/authme/util/RandomStringUtils.java diff --git a/project/module-util/src/main/java/fr/xephi/authme/util/StringUtil.java b/project/module-util/src/main/java/fr/xephi/authme/util/StringUtil.java deleted file mode 100644 index 1b65a904..00000000 --- a/project/module-util/src/main/java/fr/xephi/authme/util/StringUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -package fr.xephi.authme.util; - -/** - * StringUtil - * - * @author TheFloodDragon - * @since 2024/7/10 19:51 - */ -public final class StringUtil { - - private StringUtil() { - } - - /** - * 解码 Unicode - */ - public static String decodeUnicode(String str) { - String r = str; - int i = r.indexOf("\\u"); - if (i != -1) { - r = r.substring(0, i) + (char) Integer.parseInt(r.substring(i + 2, i + 6), 16) + r.substring(i + 6); - decodeUnicode(r); - } - return r; - } - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/StringUtils.java b/project/module-util/src/main/java/fr/xephi/authme/util/StringUtils.java similarity index 87% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/StringUtils.java rename to project/module-util/src/main/java/fr/xephi/authme/util/StringUtils.java index 8a863678..7b1ba555 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/StringUtils.java +++ b/project/module-util/src/main/java/fr/xephi/authme/util/StringUtils.java @@ -67,7 +67,7 @@ public final class StringUtils { * Checks that the given needle is in the middle of the haystack, i.e. that the haystack * contains the needle and that it is not at the very start or end. * - * @param needle the needle to search for + * @param needle the needle to search for * @param haystack the haystack to search in * @return true if the needle is in the middle of the word, false otherwise */ @@ -77,4 +77,18 @@ public final class StringUtils { int index = haystack.indexOf(needle); return index > 0 && index < haystack.length() - 1; } + + /** + * 解码 Unicode + */ + public static String decodeUnicode(String str) { + String r = str; + int i = r.indexOf("\\u"); + if (i != -1) { + r = r.substring(0, i) + (char) Integer.parseInt(r.substring(i + 2, i + 6), 16) + r.substring(i + 6); + decodeUnicode(r); + } + return r; + } + } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/UuidUtils.java b/project/module-util/src/main/java/fr/xephi/authme/util/UuidUtils.java similarity index 100% rename from plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/UuidUtils.java rename to project/module-util/src/main/java/fr/xephi/authme/util/UuidUtils.java