mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Add a sanity check to prevent loading null configs
This commit is contained in:
@@ -172,12 +172,20 @@ public class LunarCore {
|
|||||||
// Config
|
// Config
|
||||||
|
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
|
// Load from file
|
||||||
try (FileReader file = new FileReader(configFile)) {
|
try (FileReader file = new FileReader(configFile)) {
|
||||||
config = JsonUtils.loadToClass(file, Config.class);
|
LunarCore.config = JsonUtils.loadToClass(file, Config.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check
|
||||||
|
if (LunarCore.getConfig() == null) {
|
||||||
LunarCore.config = new Config();
|
LunarCore.config = new Config();
|
||||||
}
|
}
|
||||||
saveConfig();
|
|
||||||
|
// Save config
|
||||||
|
LunarCore.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveConfig() {
|
public static void saveConfig() {
|
||||||
|
|||||||
Reference in New Issue
Block a user