From 58d8ba2358fbc9a6ed2ba54897d1bcf5357b0111 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:52:46 +0700 Subject: [PATCH] [FIX] 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);