3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Fix config read/write error when parent file is null (#3783)

Dieser Commit ist enthalten in:
RK_01 2024-04-10 17:35:25 +02:00 committet von GitHub
Ursprung 0c2c8400ae
Commit 2586788bf6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -21,9 +21,6 @@ import com.google.gson.JsonElement;
import com.viaversion.viaversion.compatibility.YamlCompat; import com.viaversion.viaversion.compatibility.YamlCompat;
import com.viaversion.viaversion.compatibility.unsafe.Yaml1Compat; import com.viaversion.viaversion.compatibility.unsafe.Yaml1Compat;
import com.viaversion.viaversion.compatibility.unsafe.Yaml2Compat; import com.viaversion.viaversion.compatibility.unsafe.Yaml2Compat;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -35,6 +32,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
@SuppressWarnings("VulnerableCodeUsages") @SuppressWarnings("VulnerableCodeUsages")
public abstract class Config { public abstract class Config {
@ -148,7 +148,9 @@ public abstract class Config {
} }
public void save() { public void save() {
this.configFile.getParentFile().mkdirs(); if (this.configFile.getParentFile() != null) {
this.configFile.getParentFile().mkdirs();
}
save(this.configFile, this.config); save(this.configFile, this.config);
} }
@ -157,7 +159,9 @@ public abstract class Config {
} }
public void reload() { public void reload() {
this.configFile.getParentFile().mkdirs(); if (this.configFile.getParentFile() != null) {
this.configFile.getParentFile().mkdirs();
}
this.config = new ConcurrentSkipListMap<>(loadConfig(this.configFile)); this.config = new ConcurrentSkipListMap<>(loadConfig(this.configFile));
} }
@ -245,4 +249,4 @@ public abstract class Config {
return null; return null;
} }
} }
} }