diff --git a/build.gradle.kts b/build.gradle.kts index cf63f86b..c9e85e9c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,9 +24,6 @@ subprojects { val platformName = project.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } archiveFileName.set("EpicGuard$platformName-${project.version}.jar") - relocate("com.fasterxml", "me.xneox.epicguard.libs.fasterxml") - relocate("com.maxmind", "me.xneox.epicguard.libs.maxmind") - minimize() // Copy compiled platform jars to '/build' directory for convenience. diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 069fbed0..1257cbe8 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } dependencies { - implementation(libs.geoip) + compileOnly(libs.geoip) compileOnly(libs.commons.compress) compileOnly(libs.commons.text) compileOnly(libs.guava) @@ -41,7 +41,9 @@ blossom { replaceToken("{caffeine}", libs.versions.caffeine.get()) replaceToken("{common-compress}", libs.versions.commons.compress.get()) replaceToken("{common-text}", libs.versions.commons.text.get()) - + replaceToken("{geoip}", libs.versions.geoip.get()) + replaceToken("{jackson}", libs.versions.jackson.get()) + replaceToken("{maxmind-db}", libs.versions.maxmind.db.get()) } // Publish to Maven Central diff --git a/core/src/main/java/me/xneox/epicguard/core/util/VersionUtils.java b/core/src/main/java/me/xneox/epicguard/core/util/VersionUtils.java index e7932add..03d1be59 100644 --- a/core/src/main/java/me/xneox/epicguard/core/util/VersionUtils.java +++ b/core/src/main/java/me/xneox/epicguard/core/util/VersionUtils.java @@ -29,6 +29,9 @@ public final class VersionUtils { public static final String CAFFEINE = "{caffeine}"; public static final String COMMONS_TEXT = "{common-text}"; public static final String COMMANDS_COMPRESS = "{common-compress}"; + public static final String GEOIP = "{geoip}"; + public static final String JACKSON = "{jackson}"; + public static final String MAXMIND_DB = "{maxmind-db}"; private static final String CHECK_URL = "https://raw.githubusercontent.com/4drian3d/EpicGuard/master/VERSION.txt"; private static boolean updateAvailable; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1a19c16c..fddce179 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,6 +38,8 @@ commons-compress = "1.23.0" commons-text = "1.10.0" geoip = "4.0.1" +jackson = "2.14.2" +maxmind-db = "3.0.0" caffeine = "3.1.6" @@ -73,6 +75,10 @@ commons-text = { group = "org.apache.commons", name = "commons-text", version.re commons-compress = { group = "org.apache.commons", name = "commons-compress", version.ref = "commons-compress" } geoip = { group = "com.maxmind.geoip2", name = "geoip2", version.ref = "geoip" } +maxmind-db = { group = "com.maxmind.db", name = "maxmind-db", version.ref = "maxmind-db" } +jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" } +jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" } +jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" } diff --git a/paper/src/main/java/me/xneox/epicguard/paper/LibraryLoader.java b/paper/src/main/java/me/xneox/epicguard/paper/LibraryLoader.java index 810106dc..ad12f39a 100644 --- a/paper/src/main/java/me/xneox/epicguard/paper/LibraryLoader.java +++ b/paper/src/main/java/me/xneox/epicguard/paper/LibraryLoader.java @@ -9,6 +9,8 @@ import org.eclipse.aether.repository.RemoteRepository; import org.jetbrains.annotations.NotNull; +import java.util.stream.Stream; + @SuppressWarnings({"unused", "UnstableApiUsage"}) public class LibraryLoader implements PluginLoader { @Override @@ -18,33 +20,22 @@ public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { final RemoteRepository mavenCentral = new RemoteRepository .Builder("central", "default", "https://repo1.maven.org/maven2/") .build(); - final Dependency configurateHocon = new Dependency( - new DefaultArtifact("org.spongepowered:configurate-hocon:"+VersionUtils.CONFIGURATE), - null - ); - final Dependency hikari = new Dependency( - new DefaultArtifact("com.zaxxer:HikariCP:"+ VersionUtils.HIKARI), - null - ); - final Dependency caffeine = new Dependency( - new DefaultArtifact("com.github.ben-manes.caffeine:caffeine:"+ VersionUtils.CAFFEINE), - null - ); - final Dependency compress = new Dependency( - new DefaultArtifact("org.apache.commons:commons-compress:"+ VersionUtils.COMMANDS_COMPRESS), - null - ); - final Dependency text = new Dependency( - new DefaultArtifact("org.apache.commons:commons-text:"+ VersionUtils.COMMONS_TEXT), - null - ); - resolver.addRepository(mavenCentral); - resolver.addDependency(configurateHocon); - resolver.addDependency(hikari); - resolver.addDependency(caffeine); - resolver.addDependency(compress); - resolver.addDependency(text); + + Stream.of( + "org.spongepowered:configurate-hocon:" + VersionUtils.CONFIGURATE, + "com.zaxxer:HikariCP:" + VersionUtils.HIKARI, + "com.github.ben-manes.caffeine:caffeine:" + VersionUtils.CAFFEINE, + "org.apache.commons:commons-compress:" + VersionUtils.COMMANDS_COMPRESS, + "org.apache.commons:commons-text:" + VersionUtils.COMMONS_TEXT, + "com.maxmind.geoip2:geoip2:" + VersionUtils.GEOIP, + "com.maxmind.db:maxmind-db:" + VersionUtils.MAXMIND_DB, + "com.fasterxml.jackson.core:jackson-annotations:" + VersionUtils.JACKSON, + "com.fasterxml.jackson.core:jackson-core:" + VersionUtils.JACKSON, + "com.fasterxml.jackson.core:jackson-databind:" + VersionUtils.JACKSON + ) + .map(artifact -> new Dependency(new DefaultArtifact(artifact), null)) + .forEach(resolver::addDependency); classpathBuilder.addLibrary(resolver); } diff --git a/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java b/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java index 05c8fc07..9a79c800 100644 --- a/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java +++ b/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java @@ -97,6 +97,36 @@ void register() { .id("commons-text") .relocate(commonsRelocation) .build(); + final Library MAXMIND_GEOIP = Library.builder() + .groupId("com.maxmind.geoip2") + .artifactId("geoip2") + .version(VersionUtils.GEOIP) + .id("geoip2") + .build(); + final Library MAXMIND_DB = Library.builder() + .groupId("com.maxmind.db") + .artifactId("maxmind-db") + .version(VersionUtils.MAXMIND_DB) + .id("maxmind-db") + .build(); + final Library JACKSON_ANNOTATIONS = Library.builder() + .groupId("com.fasterxml.jackson.core") + .artifactId("jackson-annotations") + .version(VersionUtils.JACKSON) + .id("jackson-annotations") + .build(); + final Library JACKSON_CORE = Library.builder() + .groupId("com.fasterxml.jackson.core") + .artifactId("jackson-core") + .version(VersionUtils.JACKSON) + .id("jackson-core") + .build(); + final Library JACKSON_DATABIND = Library.builder() + .groupId("com.fasterxml.jackson.core") + .artifactId("jackson-databind") + .version(VersionUtils.JACKSON) + .id("jackson-databind") + .build(); manager.addMavenCentral(); manager.loadLibrary(SQLITE); @@ -107,6 +137,11 @@ void register() { manager.loadLibrary(HIKARI); manager.loadLibrary(COMMONS_COMPRESS); manager.loadLibrary(COMMONS_TEXT); + manager.loadLibrary(MAXMIND_GEOIP); + manager.loadLibrary(MAXMIND_DB); + manager.loadLibrary(JACKSON_ANNOTATIONS); + manager.loadLibrary(JACKSON_CORE); + manager.loadLibrary(JACKSON_DATABIND); } } diff --git a/waterfall/build.gradle.kts b/waterfall/build.gradle.kts index 305cd612..e222d17e 100644 --- a/waterfall/build.gradle.kts +++ b/waterfall/build.gradle.kts @@ -25,12 +25,18 @@ bungee { version = project.version as String author = "neox, 4drian3d" libraries = listOf( - "${libs.adventure.platform.bungeecord.get().module}:${libs.versions.adventure.platform.get()}", - "${libs.sqlite.get().module}:${libs.versions.sqlite.get()}", - "${libs.caffeine.get().module}:${libs.versions.caffeine.get()}", - "${libs.hikaricp.get().module}:${libs.versions.hikaricp.get()}", - "${libs.configurate.get().module}:${libs.versions.configurate.get()}", - "${libs.commons.compress.get().module}:${libs.versions.commons.compress.get()}", - "${libs.commons.text.get().module}:${libs.versions.commons.text.get()}", - ) + libs.adventure.platform.bungeecord to libs.versions.adventure.platform, + libs.sqlite to libs.versions.sqlite, + libs.caffeine to libs.versions.caffeine, + libs.hikaricp to libs.versions.hikaricp, + libs.configurate to libs.versions.configurate, + libs.commons.compress to libs.versions.commons.compress, + libs.commons.text to libs.versions.commons.text, + libs.geoip to libs.versions.geoip, + libs.maxmind.db to libs.versions.maxmind.db, + libs.jackson.core to libs.versions.jackson, + libs.jackson.databind to libs.versions.jackson, + libs.jackson.annotations to libs.versions.jackson, + ).map { "${it.first.get().module}:${it.second.get()}" } } +