[FIX] Reset null config

This commit is contained in:
Gravita 2023-09-20 19:52:46 +07:00
parent 1cc3edd15b
commit 58d8ba2358

View file

@ -41,7 +41,13 @@ default String toJsonString() {
default void loadConfig(Gson gson, Path configPath) throws IOException {
if (generateConfigIfNotExists(configPath)) return;
try (BufferedReader reader = IOHelper.newReader(configPath)) {
setConfig(gson.fromJson(reader, getType()));
T value = gson.fromJson(reader, getType());
if(value == null) {
LogHelper.warning("Config %s is null", configPath);
resetConfig(configPath);
return;
}
setConfig(value);
} catch (Exception e) {
LogHelper.error(e);
resetConfig(configPath);