diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EcoEnchantsConfigs.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EcoEnchantsConfigs.java index 67496d77..2cffc7be 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EcoEnchantsConfigs.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EcoEnchantsConfigs.java @@ -45,9 +45,8 @@ public class EcoEnchantsConfigs { * @param permissionName The permission name to match. * @return The matching {@link EnchantmentConfig}. */ - @SuppressWarnings("OptionalGetWithoutIsPresent") public EnchantmentConfig getEnchantmentConfig(@NotNull final String permissionName) { - return enchantmentConfigs.stream().filter(config -> config.getName().equalsIgnoreCase(permissionName)).findFirst().get(); + return enchantmentConfigs.stream().filter(config -> config.getName().equalsIgnoreCase(permissionName)).findFirst().orElse(null); } /** diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index 27d8588f..e1e7b20c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -31,18 +31,13 @@ public abstract class EnchantmentYamlConfig extends PluginDependent implements V * The internal config that stores the values. */ @Getter - private YamlConfiguration config; + private final YamlConfiguration config; /** * The physical file of the config. */ @Getter(AccessLevel.PROTECTED) - private File configFile; - - /** - * The directory that the config is in. - */ - private final File directory; + private final File configFile; /** * The provider of the config. @@ -78,13 +73,12 @@ public abstract class EnchantmentYamlConfig extends PluginDependent implements V if (!dir.exists()) { dir.mkdirs(); } - this.directory = dir; - if (!new File(directory, name + ".yml").exists()) { + if (!new File(dir, name + ".yml").exists()) { createFile(); } - this.configFile = new File(directory, name + ".yml"); + this.configFile = new File(dir, name + ".yml"); this.config = YamlConfiguration.loadConfiguration(configFile); update();