Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/18.x/forge' into 19.2/forge
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Oct 8, 2023
2 parents e85ad66 + f92a389 commit 437e892
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
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 @@ -117,12 +119,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 @@ -132,7 +139,8 @@ public static SodiumGameOptions load(String name) {
config.sanitize();

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 437e892

Please sign in to comment.