From 419a29658794d2cd32411201ec772a1edda5bec3 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Thu, 19 Sep 2024 22:41:25 +0200 Subject: [PATCH] Fix broken root folder reference in VV platform Closes https://github.com/ViaVersion/ViaFabricPlus/issues/567 --- .../protocoltranslator/ProtocolTranslator.java | 10 +++++----- .../platform/ViaFabricPlusViaVersionPlatformImpl.java | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java index 70918c76..0d25a5b4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java @@ -265,13 +265,13 @@ public class ProtocolTranslator { /** * Apply recommended config options to the ViaVersion config files * - * @param configFolder The directory where the ViaVersion config files is located + * @param directory The directory where the ViaVersion config files is located */ - private static void patchConfigs(final File configFolder) { - configFolder.mkdirs(); + private static void patchConfigs(final File directory) { + directory.mkdirs(); try { - final File viaVersionConfig = new File(configFolder, "viaversion.yml"); + final File viaVersionConfig = new File(directory, "viaversion.yml"); Files.writeString(viaVersionConfig.toPath(), """ fix-infested-block-breaking: false shield-blocking: false @@ -284,7 +284,7 @@ public class ProtocolTranslator { } try { - final File viaLegacyConfig = new File(configFolder, "vialegacy.yml"); + final File viaLegacyConfig = new File(directory, "vialegacy.yml"); Files.writeString(viaLegacyConfig.toPath(), """ legacy-skull-loading: true legacy-skin-loading: true diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/platform/ViaFabricPlusViaVersionPlatformImpl.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/platform/ViaFabricPlusViaVersionPlatformImpl.java index ffa36031..b08f6743 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/platform/ViaFabricPlusViaVersionPlatformImpl.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/platform/ViaFabricPlusViaVersionPlatformImpl.java @@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.protocoltranslator.impl.platform; import com.viaversion.viaversion.configuration.AbstractViaConfig; import com.viaversion.viaversion.libs.gson.JsonArray; import com.viaversion.viaversion.libs.gson.JsonObject; +import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.protocoltranslator.impl.viaversion.ViaFabricPlusVLViaConfig; @@ -32,16 +33,14 @@ import java.io.File; public class ViaFabricPlusViaVersionPlatformImpl extends ViaVersionPlatformImpl { - private final File rootFolder; - - public ViaFabricPlusViaVersionPlatformImpl(File rootFolder) { + public ViaFabricPlusViaVersionPlatformImpl(File rootFolder) { // Only required to not throw an exception, not used super(rootFolder); - this.rootFolder = rootFolder; } @Override protected AbstractViaConfig createConfig() { - return new ViaFabricPlusVLViaConfig(new File(this.getDataFolder(), "viaversion.yml"), this.getLogger()); + // Use config overload and change directory to root folder + return new ViaFabricPlusVLViaConfig(new File(getDataFolder(), "viaversion.yml"), this.getLogger()); } @Override @@ -80,7 +79,7 @@ public class ViaFabricPlusViaVersionPlatformImpl extends ViaVersionPlatformImpl @Override public File getDataFolder() { // Move ViaLoader files directly into root folder - return this.rootFolder; + return ViaFabricPlus.global().getDirectory(); } }