diff options
| author | Aizistral | 2022-08-30 12:11:59 +0200 |
|---|---|---|
| committer | Aizistral | 2022-08-30 12:12:07 +0200 |
| commit | 57d211773ccf143aa2fcd4b428de8101c59bde98 (patch) | |
| tree | 1a0a95258fa3be46ae09f5a834aa24bfede85371 | |
| parent | e1b2655babada06867af0067cab93add462c8878 (diff) | |
Add `getDefault` method to `JSONConfig`
3 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java b/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java index 69f3ef3..3369439 100644 --- a/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java @@ -52,6 +52,8 @@ public abstract class JSONConfig { // NO-OP } + public abstract JSONConfig getDefault(); + public static <T extends JSONConfig> T loadConfig(Class<T> configClass, Supplier<T> freshInstance, String fileName) { NoChatReports.LOGGER.info("Reading config file {}...", fileName); T config = readFile(fileName, configClass).orElseGet(freshInstance); diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java index 0ab4db9..a07c92d 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java @@ -25,6 +25,11 @@ public final class NCRClientConfig extends JSONConfig { super(FILE_NAME); } + @Override + public NCRClientConfig getDefault() { + return new NCRClientConfig(); + } + /** * @return True if client with No Chat Reports installed should demand that mod is present on * every server that it tries to join. In that case client will not be able to join servers that diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java index 65bbfc6..509100f 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java @@ -17,6 +17,11 @@ public final class NCRCommonConfig extends JSONConfig { super(FILE_NAME); } + @Override + public NCRCommonConfig getDefault() { + return new NCRCommonConfig(); + } + /** * @return True if server with No Chat Reports installed should demand that mod is present on * every client that tries to join. Mod's installation on client is optional otherwise.<br><br> |
