Move some utils and loggers
This commit is contained in:
parent
97c703a45c
commit
d2ab029597
@ -1,5 +1,10 @@
|
|||||||
[versions]
|
[versions]
|
||||||
guava = "33.2.1-jre"
|
guava = "33.2.1-jre"
|
||||||
|
adventure = "4.17.0"
|
||||||
|
adventure-platform = "4.3.2"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
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" }
|
||||||
@ -32,8 +32,6 @@ subprojects {
|
|||||||
compileOnly("org.geysermc.floodgate:api:2.2.2-SNAPSHOT")
|
compileOnly("org.geysermc.floodgate:api:2.2.2-SNAPSHOT")
|
||||||
// Jalu Injector
|
// Jalu Injector
|
||||||
implementation("ch.jalu:injector:1.0")
|
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
|
// 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
|
// 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") {
|
implementation("com.maxmind.db:maxmind-db-gson:2.0.3") {
|
||||||
@ -43,7 +41,7 @@ subprojects {
|
|||||||
implementation("javatar:javatar:2.5")
|
implementation("javatar:javatar:2.5")
|
||||||
// Java Email Library
|
// Java Email Library
|
||||||
implementation("org.apache.commons:commons-email:1.6-SNAPSHOT")
|
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
|
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")
|
||||||
@ -77,8 +75,8 @@ subprojects {
|
|||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
// Adventure API
|
// Adventure API
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
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-text-serializer-gson:4.17.0")
|
||||||
|
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
|
||||||
// LuckPerms plugin
|
// LuckPerms plugin
|
||||||
compileOnly("net.luckperms:api:5.4")
|
compileOnly("net.luckperms:api:5.4")
|
||||||
// PermissionsEx plugin
|
// PermissionsEx plugin
|
||||||
@ -143,7 +141,6 @@ subprojects {
|
|||||||
relocate("org.slf4j", "fr.xephi.authme.libs.org.slf4j")
|
relocate("org.slf4j", "fr.xephi.authme.libs.org.slf4j")
|
||||||
relocate("com.maxmind.db", "fr.xephi.authme.libs.com.maxmind.db")
|
relocate("com.maxmind.db", "fr.xephi.authme.libs.com.maxmind.db")
|
||||||
relocate("com.ice.tar", "fr.xephi.authme.libs.com.icetar.tar")
|
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("de.rtner", "fr.xephi.authme.libs.de.rtner")
|
||||||
relocate("org.picketbox", "fr.xephi.authme.libs.org.picketbox")
|
relocate("org.picketbox", "fr.xephi.authme.libs.org.picketbox")
|
||||||
relocate("org.jboss.crypto", "fr.xephi.authme.libs.org.jboss.crypto")
|
relocate("org.jboss.crypto", "fr.xephi.authme.libs.org.jboss.crypto")
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
private final File authMeConfigurationFile;
|
private final File authMeConfigurationFile;
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
private final PluginHookService pluginHookService;
|
private final PluginHookService pluginHookService;
|
||||||
private Configuration authMeConfiguration;
|
private FileConfiguration authMeConfiguration;
|
||||||
private String[] spawnPriority;
|
private String[] spawnPriority;
|
||||||
private Location essentialsSpawn;
|
private Location essentialsSpawn;
|
||||||
private Location cmiSpawn;
|
private Location cmiSpawn;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import com.electronwill.nightconfig.core.CommentedConfig
|
|||||||
import com.electronwill.nightconfig.core.Config
|
import com.electronwill.nightconfig.core.Config
|
||||||
import com.electronwill.nightconfig.core.EnumGetMethod
|
import com.electronwill.nightconfig.core.EnumGetMethod
|
||||||
import fr.xephi.authme.util.Coerce
|
import fr.xephi.authme.util.Coerce
|
||||||
import fr.xephi.authme.util.StringUtil
|
import fr.xephi.authme.util.StringUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigSection
|
* ConfigSection
|
||||||
@ -87,7 +87,7 @@ open class ConfigSection(
|
|||||||
value is List<*> -> root.set<Any>(path, unwrap(value, this))
|
value is List<*> -> root.set<Any>(path, unwrap(value, this))
|
||||||
value is Collection<*> && value !is List<*> -> set(path, value.toList())
|
value is Collection<*> && value !is List<*> -> set(path, value.toList())
|
||||||
value is ConfigurationSection -> set(path, value.getConfig())
|
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 -> {
|
value is Commented -> {
|
||||||
set(path, value.value)
|
set(path, value.value)
|
||||||
setComment(path, value.comment)
|
setComment(path, value.comment)
|
||||||
@ -294,7 +294,7 @@ open class ConfigSection(
|
|||||||
return if (this is ConfigSection) root else error("Not supported")
|
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())
|
val section = ConfigSection(parent.root.createSubConfig())
|
||||||
forEach { (k, v) -> section[k.toString()] = v }
|
forEach { (k, v) -> section[k.toString()] = v }
|
||||||
return section.root
|
return section.root
|
||||||
@ -326,7 +326,7 @@ open class ConfigSection(
|
|||||||
value is List<*> -> unwrap(value, parent)
|
value is List<*> -> unwrap(value, parent)
|
||||||
value is Collection<*> && value !is List<*> -> value.toList()
|
value is Collection<*> && value !is List<*> -> value.toList()
|
||||||
value is ConfigurationSection -> value.getConfig()
|
value is ConfigurationSection -> value.getConfig()
|
||||||
value is Map<*, *> -> value.asConfig(parent)
|
value is Map<*, *> -> value.toConfig(parent)
|
||||||
else -> value
|
else -> value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly(project(":project:module-util"))
|
||||||
compileOnly(libs.guava)
|
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
|
||||||
}
|
}
|
||||||
@ -1,3 +1,11 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.guava)
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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
|
* 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.
|
* 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
|
* @param haystack the haystack to search in
|
||||||
* @return true if the needle is in the middle of the word, false otherwise
|
* @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);
|
int index = haystack.indexOf(needle);
|
||||||
return index > 0 && index < haystack.length() - 1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user