Fix broken root folder reference in VV platform

Closes https://github.com/ViaVersion/ViaFabricPlus/issues/567
This commit is contained in:
FlorianMichael 2024-09-19 22:41:25 +02:00
parent 67f51ffd93
commit 419a296587
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 10 additions and 11 deletions

View File

@ -265,13 +265,13 @@ public class ProtocolTranslator {
/** /**
* Apply recommended config options to the ViaVersion config files * 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) { private static void patchConfigs(final File directory) {
configFolder.mkdirs(); directory.mkdirs();
try { try {
final File viaVersionConfig = new File(configFolder, "viaversion.yml"); final File viaVersionConfig = new File(directory, "viaversion.yml");
Files.writeString(viaVersionConfig.toPath(), """ Files.writeString(viaVersionConfig.toPath(), """
fix-infested-block-breaking: false fix-infested-block-breaking: false
shield-blocking: false shield-blocking: false
@ -284,7 +284,7 @@ public class ProtocolTranslator {
} }
try { try {
final File viaLegacyConfig = new File(configFolder, "vialegacy.yml"); final File viaLegacyConfig = new File(directory, "vialegacy.yml");
Files.writeString(viaLegacyConfig.toPath(), """ Files.writeString(viaLegacyConfig.toPath(), """
legacy-skull-loading: true legacy-skull-loading: true
legacy-skin-loading: true legacy-skin-loading: true

View File

@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.protocoltranslator.impl.platform;
import com.viaversion.viaversion.configuration.AbstractViaConfig; import com.viaversion.viaversion.configuration.AbstractViaConfig;
import com.viaversion.viaversion.libs.gson.JsonArray; import com.viaversion.viaversion.libs.gson.JsonArray;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin; import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
import de.florianmichael.viafabricplus.protocoltranslator.impl.viaversion.ViaFabricPlusVLViaConfig; import de.florianmichael.viafabricplus.protocoltranslator.impl.viaversion.ViaFabricPlusVLViaConfig;
@ -32,16 +33,14 @@ import java.io.File;
public class ViaFabricPlusViaVersionPlatformImpl extends ViaVersionPlatformImpl { public class ViaFabricPlusViaVersionPlatformImpl extends ViaVersionPlatformImpl {
private final File rootFolder; public ViaFabricPlusViaVersionPlatformImpl(File rootFolder) { // Only required to not throw an exception, not used
public ViaFabricPlusViaVersionPlatformImpl(File rootFolder) {
super(rootFolder); super(rootFolder);
this.rootFolder = rootFolder;
} }
@Override @Override
protected AbstractViaConfig createConfig() { 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 @Override
@ -80,7 +79,7 @@ public class ViaFabricPlusViaVersionPlatformImpl extends ViaVersionPlatformImpl
@Override @Override
public File getDataFolder() { public File getDataFolder() {
// Move ViaLoader files directly into root folder // Move ViaLoader files directly into root folder
return this.rootFolder; return ViaFabricPlus.global().getDirectory();
} }
} }