Fixed bugs with new config system
This commit is contained in:
@@ -3,9 +3,9 @@ package com.willfp.eco.util.config;
|
||||
import com.willfp.eco.util.config.internal.AbstractUpdatableConfig;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class BaseConfig extends AbstractUpdatableConfig {
|
||||
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
* <p>
|
||||
@@ -19,7 +19,22 @@ public abstract class BaseConfig extends AbstractUpdatableConfig {
|
||||
protected BaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final AbstractEcoPlugin plugin,
|
||||
@Nullable final String... updateBlacklist) {
|
||||
super(configName, plugin, "/", plugin.getClass(), removeUnused, updateBlacklist);
|
||||
@NotNull final String... updateBlacklist) {
|
||||
super(configName, plugin, "", plugin.getClass(), removeUnused, updateBlacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
* <p>
|
||||
* Automatically updates.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected BaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(configName, plugin, "", plugin.getClass(), removeUnused, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ public abstract class StaticBaseConfig extends AbstractConfig {
|
||||
*/
|
||||
protected StaticBaseConfig(@NotNull final String configName,
|
||||
@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(configName, plugin, "/", plugin.getClass());
|
||||
super(configName, plugin, "", plugin.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.willfp.eco.util.config;
|
||||
|
||||
@Deprecated
|
||||
public interface ValueGetter {
|
||||
}
|
||||
@@ -121,10 +121,10 @@ public abstract class AbstractConfig extends PluginDependent {
|
||||
if (subDirectoryPath.isEmpty()) {
|
||||
resourcePath = name;
|
||||
} else {
|
||||
resourcePath = "/" + subDirectoryPath + name;
|
||||
resourcePath = subDirectoryPath + name;
|
||||
}
|
||||
|
||||
return resourcePath;
|
||||
return "/" + resourcePath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +136,7 @@ public abstract class AbstractConfig extends PluginDependent {
|
||||
InputStream newIn = source.getResourceAsStream(getResourcePath());
|
||||
|
||||
if (newIn == null) {
|
||||
this.getPlugin().getLog().error(this.getName() + " is null?");
|
||||
return null;
|
||||
throw new NullPointerException(this.getName() + " is null?");
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,10 +36,11 @@ public abstract class AbstractUpdatableConfig extends AbstractConfig {
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final Class<?> source,
|
||||
final boolean removeUnused,
|
||||
@Nullable final String... updateBlacklist) {
|
||||
@NotNull final String... updateBlacklist) {
|
||||
super(configName, plugin, subDirectoryPath, source);
|
||||
this.removeUnused = removeUnused;
|
||||
this.updateBlacklist = Arrays.asList(updateBlacklist);
|
||||
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
|
||||
this.updateBlacklist.removeIf(String::isEmpty);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user