diff --git a/api-legacy/gradle.properties b/api-legacy/gradle.properties new file mode 100644 index 000000000..01bcc9b37 --- /dev/null +++ b/api-legacy/gradle.properties @@ -0,0 +1 @@ +maven_description=Legacy compatibility for mods using the ViaFabricPlus pre 4.0.0 API. \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 21e34d8ff..0ec25a733 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -21,7 +21,9 @@ package de.florianmichael.viafabricplus; +import de.florianmichael.viafabricplus.save.SaveManager; import de.florianmichael.viafabricplus.settings.SettingsManager; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; @@ -34,7 +36,10 @@ public class ViaFabricPlus { private static final ViaFabricPlus INSTANCE = new ViaFabricPlus(); + private final Logger logger = LogManager.getLogger("ViaFabricPlus-Legacy"); + private final SettingsManager settingsManager = new SettingsManager(); + private final SaveManager saveManager = new SaveManager(); @Deprecated public static ViaFabricPlus global() { @@ -43,7 +48,7 @@ public static ViaFabricPlus global() { @Deprecated public Logger getLogger() { - return com.viaversion.viafabricplus.ViaFabricPlus.getImpl().logger(); + return logger; } @Deprecated @@ -52,13 +57,13 @@ public File getDirectory() { } @Deprecated - public Object getSettingsManager() { + public SettingsManager getSettingsManager() { return settingsManager; } @Deprecated - public Object getSaveManager() { - throw new IllegalArgumentException("ViaFabricPlus#getSaveManager is not supported anymore."); + public SaveManager getSaveManager() { + return saveManager; } } \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/save/SaveManager.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/save/SaveManager.java new file mode 100644 index 000000000..c484d9449 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/save/SaveManager.java @@ -0,0 +1,30 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.save; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public class SaveManager { + +} diff --git a/api/gradle.properties b/api/gradle.properties new file mode 100644 index 000000000..c3ece96a0 --- /dev/null +++ b/api/gradle.properties @@ -0,0 +1 @@ +maven_description=Interface for third-party mods to interact with ViaFabricPlus internals. \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java index 686b6c373..54781a043 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java @@ -33,7 +33,6 @@ import net.minecraft.client.network.ServerInfo; import net.minecraft.item.ItemStack; import net.minecraft.network.ClientConnection; -import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; @@ -51,13 +50,6 @@ default int apiVersion() { return 1; } - /** - * Get the logger for this mod. - * - * @return The logger - */ - Logger logger(); - /** * Get the root path of the mod. * @@ -103,13 +95,6 @@ default int apiVersion() { */ void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect); - /** - * @param clientVersion The client version - * @param serverVersion The server version - * @return Creates a dummy UserConnection class with a valid protocol pipeline to emulate packets - */ - UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion); - /** * @return the current UserConnection of the connection to the server, if the player isn't connected to a server it will return null */ diff --git a/build-logic/src/main/groovy/vfp.base-conventions.gradle b/build-logic/src/main/groovy/vfp.base-conventions.gradle index dfd32a040..4d728974d 100644 --- a/build-logic/src/main/groovy/vfp.base-conventions.gradle +++ b/build-logic/src/main/groovy/vfp.base-conventions.gradle @@ -53,6 +53,15 @@ java { targetCompatibility = JavaVersion.VERSION_21 } +processResources { + filesMatching("fabric.mod.json") { + expand( + "version": project.version, + "description": project.description + ) + } +} + publishing { repositories { maven { diff --git a/build.gradle b/build.gradle index 0d9c12471..585df3b35 100644 --- a/build.gradle +++ b/build.gradle @@ -11,9 +11,14 @@ loom { } configurations { + pij // project in jar configuration jij // jar in jar configuration modJij // jar in jar configuration for mods + include.extendsFrom pij + implementation.extendsFrom pij + compileOnlyApi.extendsFrom pij + include.extendsFrom modJij modImplementation.extendsFrom modJij modCompileOnlyApi.extendsFrom modJij @@ -28,12 +33,9 @@ dependencies { modJij fabricApi.module("fabric-particles-v1", project.fabric_api_version) modJij fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version) - // Manually include to ignore dependencies - include implementation(compileOnlyApi(project(path: ":viafabricplus-api", configuration: "namedElements"))) - include implementation(compileOnlyApi(project(path: ":viafabricplus-visuals", configuration: "namedElements"))) - - // Will be removed in future versions - include implementation(compileOnlyApi(project(":viafabricplus-api-legacy"))) + pij project(path: ":viafabricplus-api", configuration: "namedElements") + pij project(path: ":viafabricplus-api-legacy", configuration: "namedElements") + pij project(path: ":viafabricplus-visuals", configuration: "namedElements") jij "com.viaversion:viaversion-common:${project.viaversion_version}" jij "com.viaversion:viabackwards-common:${project.viabackwards_version}" @@ -77,8 +79,6 @@ dependencies { processResources { filesMatching("fabric.mod.json") { expand( - "version": project.version, - "description": project.description, "implVersion": "git-${project.name}-${project.version}:${latestCommitHash().get()}", "mcVersion": mcVersion() ) diff --git a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java index 99684d3e0..2380126d4 100644 --- a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java +++ b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java @@ -144,11 +144,6 @@ public void init() { // -------------------------------------------------------------------------------------------- // Proxy the most important/used internals to a general API point for mods - @Override - public Logger logger() { - return logger; - } - @Override public Path rootPath() { return path; @@ -179,11 +174,6 @@ public void setTargetVersion(ProtocolVersion newVersion, boolean revertOnDisconn ProtocolTranslator.setTargetVersion(newVersion, revertOnDisconnect); } - @Override - public UserConnection createDummyUserConnection(ProtocolVersion clientVersion, ProtocolVersion serverVersion) { - return ProtocolTranslator.createDummyUserConnection(clientVersion, serverVersion); - } - @Override public UserConnection getPlayNetworkUserConnection() { return ProtocolTranslator.getPlayNetworkUserConnection(); diff --git a/visuals/build.gradle b/visuals/build.gradle index ba8798458..f4e0b9baa 100644 --- a/visuals/build.gradle +++ b/visuals/build.gradle @@ -16,12 +16,3 @@ dependencies { compileOnly "net.raphimc:ViaLoader:${project.vialoader_version}" compileOnly "net.raphimc:ViaLegacy:${project.vialegacy_version}" } - -processResources { - filesMatching("fabric.mod.json") { - expand( - "version": project.version, - "description": project.description - ) - } -} \ No newline at end of file