From 57d211773ccf143aa2fcd4b428de8101c59bde98 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Tue, 30 Aug 2022 12:11:59 +0200 Subject: Add `getDefault` method to `JSONConfig` --- src/main/java/com/aizistral/nochatreports/config/JSONConfig.java | 2 ++ .../java/com/aizistral/nochatreports/config/NCRClientConfig.java | 5 +++++ .../java/com/aizistral/nochatreports/config/NCRCommonConfig.java | 5 +++++ 3 files changed, 12 insertions(+) (limited to 'src/main/java/com/aizistral') 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 loadConfig(Class configClass, Supplier 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.

-- cgit v1.2.3