Skip to content

Commit

Permalink
Fix broken root folder reference in VV platform
Browse files Browse the repository at this point in the history
Closes #567
  • Loading branch information
FlorianMichael committed Sep 19, 2024
1 parent 67f51ff commit 419a296
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ public static UserConnection getPlayNetworkUserConnection() {
/**
* 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
Expand All @@ -284,7 +284,7 @@ private static void patchConfigs(final File configFolder) {
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand All @@ -32,16 +33,14 @@

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
Expand Down Expand Up @@ -80,7 +79,7 @@ public JsonObject getDump() {
@Override
public File getDataFolder() {
// Move ViaLoader files directly into root folder
return this.rootFolder;
return ViaFabricPlus.global().getDirectory();
}

}

0 comments on commit 419a296

Please sign in to comment.