Skip to content

Commit

Permalink
Use deep copied value when resetting config
Browse files Browse the repository at this point in the history
  • Loading branch information
xpple committed Jun 14, 2024
1 parent 5ddf53a commit 35eb4ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void init(ModConfigImpl modConfig) {
String fieldName = field.getName();
modConfig.getConfigs().put(fieldName, field);
try {
modConfig.getDefaults().put(fieldName, field.get(null));
modConfig.getDefaults().put(fieldName, modConfig.getGson().fromJson(modConfig.getGson().toJsonTree(field.get(null)), field.getGenericType()));
} catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void reset(String config) {
throw new IllegalArgumentException();
}
try {
field.set(null, this.defaults.get(config));
field.set(null, this.gson.fromJson(this.gson.toJsonTree(this.defaults.get(config)), field.getGenericType()));
} catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
Expand Down

0 comments on commit 35eb4ba

Please sign in to comment.