Skip to content

Commit 9429ada

Browse files
committed
Add ability to reload config at runtime
1 parent d2f3968 commit 9429ada

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

common/src/main/java/dev/xpple/betterconfig/api/ModConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,11 @@ public interface ModConfig<P> {
125125
* @return {@code true} if the configuration was successfully saved, {@code false} otherwise
126126
*/
127127
boolean save();
128+
129+
/**
130+
* Reload this configuration. Every config field that is not marked as {@link Config#temporary()}
131+
* will be set based on the value in the config file. Temporary configs remain unchanged. No
132+
* change hooks will fire.
133+
*/
134+
void reload();
128135
}

common/src/main/java/dev/xpple/betterconfig/impl/ModConfigImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,9 @@ public boolean save() {
304304
}
305305
return true;
306306
}
307+
308+
@Override
309+
public void reload() {
310+
BetterConfigInternals.init(this);
311+
}
307312
}

0 commit comments

Comments
 (0)