From 54eaccca0dadbca69d39b91bdf51a0587cb4a9e0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 9 Jan 2022 18:58:44 +0100 Subject: [PATCH] Update Sponge module to API v8 --- .../kotlin/vb.base-conventions.gradle.kts | 2 +- build.gradle.kts | 2 +- .../api/ViaBackwardsPlatform.java | 2 +- gradle/libs.versions.toml | 6 +-- settings.gradle.kts | 1 - sponge/build.gradle.kts | 1 - .../viaversion/viabackwards/SpongePlugin.java | 33 +++++------- .../resources/META-INF/sponge_plugins.json | 50 +++++++++++++++++++ .../viabackwards/VelocityPlugin.java | 2 +- 9 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 sponge/src/main/resources/META-INF/sponge_plugins.json diff --git a/build-logic/src/main/kotlin/vb.base-conventions.gradle.kts b/build-logic/src/main/kotlin/vb.base-conventions.gradle.kts index 3b3471e5..42f6f817 100644 --- a/build-logic/src/main/kotlin/vb.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/vb.base-conventions.gradle.kts @@ -6,7 +6,7 @@ plugins { tasks { // Variable replacements processResources { - filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) { + filesMatching(listOf("plugin.yml", "META-INF/sponge_plugins.json", "fabric.mod.json", "bungee.yml")) { expand("version" to project.version, "description" to project.description, "url" to "https://github.com/ViaVersion/ViaBackwards") } } diff --git a/build.gradle.kts b/build.gradle.kts index ed0d2487..62fd6525 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.1.2-SNAPSHOT" + version = "4.2.0-SNAPSHOT" description = "Allow older clients to join newer server versions." } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index 8335e3a4..b2bf971e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -56,7 +56,7 @@ import java.util.logging.Logger; public interface ViaBackwardsPlatform { - String MINIMUM_VV_VERSION = "4.1.1"; + String MINIMUM_VV_VERSION = "4.2.0"; String IMPL_VERSION = "$IMPL_VERSION"; /** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cb32cd91..051e9867 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "4.1.0" +viaver = "4.2.0-SNAPSHOT" # Common provided netty = "4.0.20.Final" @@ -15,8 +15,8 @@ checkerQual = "3.18.0" # Platforms paper = "1.16.5-R0.1-SNAPSHOT" bungee = "1.16-R0.5-SNAPSHOT" -sponge = "5.0.0" -velocity = "3.0.0-SNAPSHOT" +sponge = "8.0.0" +velocity = "3.1.0-SNAPSHOT" fabricLoader = "0.11.6" diff --git a/settings.gradle.kts b/settings.gradle.kts index 9d769932..6ed710c9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,6 @@ dependencyResolutionManagement { maven("https://repo.viaversion.com") maven("https://papermc.io/repo/repository/maven-public/") maven("https://oss.sonatype.org/content/repositories/snapshots/") - maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/") maven("https://repo.spongepowered.org/maven") mavenCentral() } diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index 16ecd5bc..c3bca6f0 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,5 +1,4 @@ dependencies { implementation(projects.viabackwardsCommon) compileOnly(libs.sponge) - annotationProcessor(libs.sponge) } diff --git a/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java b/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java index b8719a66..e5320f2c 100644 --- a/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java +++ b/sponge/src/main/java/com/viaversion/viabackwards/SpongePlugin.java @@ -20,46 +20,39 @@ package com.viaversion.viabackwards; import com.google.inject.Inject; import com.viaversion.viabackwards.api.ViaBackwardsPlatform; -import com.viaversion.viabackwards.utils.VersionInfo; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.sponge.util.LoggerWrapper; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.Order; -import org.spongepowered.api.event.game.state.GameInitializationEvent; -import org.spongepowered.api.plugin.Dependency; -import org.spongepowered.api.plugin.Plugin; +import org.spongepowered.api.event.lifecycle.ConstructPluginEvent; +import org.spongepowered.plugin.builtin.jvm.Plugin; import java.io.File; import java.nio.file.Path; import java.util.logging.Logger; -@Plugin(id = "viabackwards", - name = "ViaBackwards", - version = VersionInfo.VERSION, - authors = {"Matsv", "kennytv", "Gerrygames", "creeper123123321", "ForceUpdate1"}, - description = "Allow older Minecraft versions to connect to a newer server version.", - dependencies = {@Dependency(id = "viaversion")} -) +@Plugin("viabackwards") public class SpongePlugin implements ViaBackwardsPlatform { - private Logger logger; - @Inject - private org.slf4j.Logger loggerSlf4j; + @SuppressWarnings("SpongeLogging") + private final Logger logger; @Inject @ConfigDir(sharedRoot = false) private Path configPath; - @Listener(order = Order.LATE) - public void onGameStart(GameInitializationEvent e) { - // Setup Logger - this.logger = new LoggerWrapper(loggerSlf4j); + @SuppressWarnings("SpongeInjection") + @Inject + SpongePlugin(final org.apache.logging.log4j.Logger logger) { + this.logger = new LoggerWrapper(logger); + } + + @Listener + public void constructPlugin(ConstructPluginEvent event) { // Init! Via.getManager().addEnableListener(() -> this.init(configPath.resolve("config.yml").toFile())); } @Override public void disable() { - // Not possible } @Override diff --git a/sponge/src/main/resources/META-INF/sponge_plugins.json b/sponge/src/main/resources/META-INF/sponge_plugins.json new file mode 100644 index 00000000..72e7569f --- /dev/null +++ b/sponge/src/main/resources/META-INF/sponge_plugins.json @@ -0,0 +1,50 @@ +{ + "loader": { + "name": "java_plain", + "version": "1.0" + }, + "license": "GNU GPLv3", + "global": { + "version": "${version}", + "links": { + "source": "https://github.com/ViaVersion/ViaBackwards", + "issues": "https://github.com/ViaVersion/ViaBackwards/issues" + }, + "contributors": [ + { + "name": "Matsv", + "description": "Maintainer" + }, + { + "name": "kennytv", + "description": "Maintainer" + }, + { + "name": "Gerrygames", + "description": "Contributor" + }, + { + "name": "creeper123123321", + "description": "Contributor" + } + ], + "dependencies": [ + { + "id": "spongeapi", + "version": "8.0.0" + }, + { + "id": "viaversion", + "version": "[4.2.0,)" + } + ] + }, + "plugins": [ + { + "id": "viabackwards", + "name": "ViaBackwards", + "entrypoint": "com.viaversion.viabackwards.SpongePlugin", + "description": "${description}" + } + ] +} \ No newline at end of file diff --git a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java index 82a491ab..b87d71ad 100644 --- a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java @@ -28,7 +28,7 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.viaversion.viabackwards.api.ViaBackwardsPlatform; import com.viaversion.viabackwards.utils.VersionInfo; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.sponge.util.LoggerWrapper; +import com.viaversion.viaversion.velocity.util.LoggerWrapper; import java.io.File; import java.nio.file.Path;