Adds a missing null check

This commit is contained in:
Kristian Knarvik 2023-11-12 19:08:06 +01:00
parent 89cebb85c3
commit 92585c4dee
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -19,6 +19,9 @@ public final class ConfigHelper {
* @return <p>The value as a string list</p>
*/
public static List<String> asStringList(Object value) {
if (value == null) {
return new ArrayList<>();
}
if (value instanceof String) {
return List.of(((String) value).split(","));
} else {