Cleaned up configs

This commit is contained in:
Auxilor 2021-02-01 15:45:31 +00:00
parent 7b9fca999d
commit 7a444e4d87
2 changed files with 5 additions and 12 deletions

View File

@ -45,9 +45,8 @@ public class EcoEnchantsConfigs {
* @param permissionName The permission name to match. * @param permissionName The permission name to match.
* @return The matching {@link EnchantmentConfig}. * @return The matching {@link EnchantmentConfig}.
*/ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public EnchantmentConfig getEnchantmentConfig(@NotNull final String permissionName) { 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);
} }
/** /**

View File

@ -31,18 +31,13 @@ public abstract class EnchantmentYamlConfig extends PluginDependent implements V
* The internal config that stores the values. * The internal config that stores the values.
*/ */
@Getter @Getter
private YamlConfiguration config; private final YamlConfiguration config;
/** /**
* The physical file of the config. * The physical file of the config.
*/ */
@Getter(AccessLevel.PROTECTED) @Getter(AccessLevel.PROTECTED)
private File configFile; private final File configFile;
/**
* The directory that the config is in.
*/
private final File directory;
/** /**
* The provider of the config. * The provider of the config.
@ -78,13 +73,12 @@ public abstract class EnchantmentYamlConfig extends PluginDependent implements V
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
} }
this.directory = dir;
if (!new File(directory, name + ".yml").exists()) { if (!new File(dir, name + ".yml").exists()) {
createFile(); createFile();
} }
this.configFile = new File(directory, name + ".yml"); this.configFile = new File(dir, name + ".yml");
this.config = YamlConfiguration.loadConfiguration(configFile); this.config = YamlConfiguration.loadConfiguration(configFile);
update(); update();