From 8f3a2097d6a9885a8a08a51dd4b7baa874ecc37c Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 12 May 2023 16:08:23 -0500 Subject: [PATCH] fix: Added Velocity runtime relocation --- settings.gradle.kts | 4 ++ velocity/build.gradle.kts | 6 +++ .../epicguard/velocity/EpicGuardVelocity.java | 2 +- .../xneox/epicguard/velocity/Libraries.java | 39 +++++++++++++++---- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index e2eb0998..5b74cb64 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,4 +10,8 @@ dependencyResolutionManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" +} + include("core", "paper", "velocity", "waterfall") \ No newline at end of file diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index a88425b6..c924c07b 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -13,6 +13,12 @@ dependencies { tasks { shadowJar { relocate("net.byteflux.libby", "me.xneox.epicguard.velocity.libby") + relocate("org.spongepowered", "me.xneox.epicguard.libs.org.spongepowered") + relocate("io.leangen.geantyref", "me.xneox.epicguard.libs.io.leangen.geantyref") + relocate("com.zaxxer.hikari", "me.xneox.epicguard.libs.com.zaxxer.hikari") + relocate("com.mysql.cj", "me.xneox.epicguard.libs.mysql") + relocate("org.xerial", "me.xneox.epicguard.libs.org.xerial") + relocate("org.apache.commons", "me.xneox.epicguard.libs.commons") } build { dependsOn(shadowJar) diff --git a/velocity/src/main/java/me/xneox/epicguard/velocity/EpicGuardVelocity.java b/velocity/src/main/java/me/xneox/epicguard/velocity/EpicGuardVelocity.java index eb5f063b..05cf7a61 100644 --- a/velocity/src/main/java/me/xneox/epicguard/velocity/EpicGuardVelocity.java +++ b/velocity/src/main/java/me/xneox/epicguard/velocity/EpicGuardVelocity.java @@ -76,7 +76,7 @@ public void onDisable(ProxyShutdownEvent e) { @Override public @NotNull String platformVersion() { - return this.server.getVersion().toString(); + return this.server.getVersion().getName() + " " + this.server.getVersion().getVersion(); } @Override 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 fa80a758..05c8fc07 100644 --- a/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java +++ b/velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java @@ -6,6 +6,7 @@ import me.xneox.epicguard.core.util.VersionUtils; import net.byteflux.libby.Library; import net.byteflux.libby.VelocityLibraryManager; +import net.byteflux.libby.relocation.Relocation; import org.slf4j.Logger; import java.nio.file.Path; @@ -20,57 +21,81 @@ final class Libraries { private EpicGuardVelocity plugin; @Inject private Logger logger; + void register() { final var manager = new VelocityLibraryManager<>(logger, folderPath, pluginManager, plugin); final Library MYSQL = Library.builder() - .groupId("com.mysql") + .groupId("com{}mysql") .artifactId("mysql-connector-j") .version("8.0.32") .id("mysql") + .relocate("com{}mysql{}cj", "me{}xneox{}epicguard{}libs{}mysql") .build(); final Library SQLITE = Library.builder() .groupId("org{}xerial") .artifactId("sqlite-jdbc") .version("3.40.1.0") .id("sqlite") - .id("mysql") + .relocate("org{}xerial", "me{}xneox{}epicguard{}libs{}org{}xerial") .build(); + + final Relocation configurateRelocation = new Relocation( + "org{}spongepowered", + "me{}xneox{}epicguard{}libs{}org{}spongepowered" + ); + final Relocation geantyrefRelocation = new Relocation( + "io{}leangen{}geantyref", + "me{}xneox{}epicguard{}libs{}io{}leangen{}geantyref" + ); final Library CONFIGURATE_HOCON = Library.builder() .groupId("org{}spongepowered") .artifactId("configurate-hocon") .version(VersionUtils.CONFIGURATE) .id("configurate-hocon") + .relocate(configurateRelocation) + .relocate(geantyrefRelocation) .build(); final Library CONFIGURATE_CORE = Library.builder() .groupId("org{}spongepowered") .artifactId("configurate-core") .version(VersionUtils.CONFIGURATE) .id("configurate-core") + .relocate(configurateRelocation) + .relocate(geantyrefRelocation) .build(); final Library GEANTYREF = Library.builder() .groupId("io{}leangen{}geantyref") .artifactId("geantyref") .version("1.3.13") .id("geantyref") + .relocate(configurateRelocation) + .relocate(geantyrefRelocation) .build(); final Library HIKARI = Library.builder() - .groupId("com.zaxxer") + .groupId("com{}zaxxer") .artifactId("HikariCP") .version(VersionUtils.HIKARI) .id("hikari") + .relocate("com{}zaxxer{}hikari", "me{}xneox{}epicguard{}libs{}com{}zaxxer{}hikari") .build(); + final Relocation commonsRelocation = new Relocation( + "org{}apache{}commons", + "me{}xneox{}epicguard{}libs{}commons" + ); final Library COMMONS_COMPRESS = Library.builder() - .groupId("org.apache.commons") + .groupId("org{}apache{}commons") .artifactId("commons-compress") .version(VersionUtils.COMMANDS_COMPRESS) - .id("hikari") + .id("commons-compress") + .relocate(commonsRelocation) .build(); final Library COMMONS_TEXT = Library.builder() - .groupId("org.apache.commons") + .groupId("org{}apache{}commons") .artifactId("commons-text") .version(VersionUtils.COMMONS_TEXT) - .id("hikari") + .id("commons-text") + .relocate(commonsRelocation) .build(); manager.addMavenCentral();