From 098eff91e63f8a8b911991a768634072512596ad Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:57:03 +0700 Subject: [PATCH] [FIX] Backport 'Reset null config' --- .../gravit/launcher/config/JsonConfigurableInterface.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java b/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java index 67b160f2..65c15c92 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java @@ -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);