Skip to content

Commit

Permalink
fix: Added Velocity runtime relocation
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed May 12, 2023
1 parent 19435ac commit 8f3a209
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ dependencyResolutionManagement {
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}

include("core", "paper", "velocity", "waterfall")
6 changes: 6 additions & 0 deletions velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 32 additions & 7 deletions velocity/src/main/java/me/xneox/epicguard/velocity/Libraries.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 8f3a209

Please sign in to comment.