From 92585c4dee387e11bde630328121bd9be14e0d54 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sun, 12 Nov 2023 19:08:06 +0100 Subject: [PATCH] Adds a missing null check --- .../java/net/knarcraft/blacksmith/BlacksmithPlugin.java | 6 +++--- .../java/net/knarcraft/blacksmith/util/ConfigHelper.java | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java index 669d591..408ace7 100644 --- a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java +++ b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java @@ -58,7 +58,7 @@ public class BlacksmithPlugin extends JavaPlugin { public void reload() { this.reloadConfig(); config.load(); - translator.loadLanguages(this.getDataFolder(), this.getConfig().getString("language", "en")); + translator.loadLanguages(this.getDataFolder(), "en", this.getConfig().getString("language", "en")); } /** @@ -90,9 +90,9 @@ public class BlacksmithPlugin extends JavaPlugin { //Copy default config to disk FileConfiguration fileConfiguration = this.getConfig(); + fileConfiguration.options().copyDefaults(true); this.saveDefaultConfig(); this.reloadConfig(); - fileConfiguration.options().copyDefaults(true); this.saveConfig(); //Load settings @@ -103,7 +103,7 @@ public class BlacksmithPlugin extends JavaPlugin { translator = new Translator(); translator.registerMessageCategory(TranslatableTimeUnit.UNIT_SECOND); translator.registerMessageCategory(BlacksmithTranslatableMessage.ITEM_TYPE_ENCHANTMENT); - translator.loadLanguages(this.getDataFolder(), fileConfiguration.getString("language", "en")); + translator.loadLanguages(this.getDataFolder(), "en", fileConfiguration.getString("language", "en")); BlacksmithPlugin.stringFormatter = new StringFormatter(this.getDescription().getPrefix(), translator); //Set up Vault integration diff --git a/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java b/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java index 6cd7245..633ca9a 100644 --- a/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java +++ b/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java @@ -19,6 +19,9 @@ public final class ConfigHelper { * @return

The value as a string list

*/ public static List asStringList(Object value) { + if (value == null) { + return new ArrayList<>(); + } if (value instanceof String) { return List.of(((String) value).split(",")); } else {