Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/19.2/forge' into 20.1/forge
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Oct 8, 2023
2 parents 1e9ee25 + 437e892 commit be8420b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import com.google.gson.JsonSyntaxException;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.gui.options.TextProvider;
import net.minecraft.client.option.GraphicsMode;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -102,12 +104,17 @@ public static SodiumGameOptions load() {
public static SodiumGameOptions load(String name) {
Path path = getConfigPath(name);
SodiumGameOptions config;
boolean resaveConfig = true;

if (Files.exists(path)) {
try (FileReader reader = new FileReader(path.toFile())) {
config = GSON.fromJson(reader, SodiumGameOptions.class);
} catch (IOException e) {
throw new RuntimeException("Could not parse config", e);
} catch (JsonSyntaxException e) {
SodiumClientMod.logger().error("Could not parse config, will fallback to default settings", e);
config = new SodiumGameOptions();
resaveConfig = false;
}
} else {
config = new SodiumGameOptions();
Expand All @@ -116,7 +123,8 @@ public static SodiumGameOptions load(String name) {
config.configPath = path;

try {
config.writeChanges();
if(resaveConfig)
config.writeChanges();
} catch (IOException e) {
throw new RuntimeException("Couldn't update config file", e);
}
Expand Down

0 comments on commit be8420b

Please sign in to comment.