Continued config changes
This commit is contained in:
@@ -2,12 +2,12 @@ package com.willfp.eco.core.config;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.wrapper.YamlConfigWrapper;
|
||||
import com.willfp.eco.core.config.wrapper.LoadableYamlConfigWrapper;
|
||||
import com.willfp.eco.core.config.wrapper.WrappedBukkitConfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class BaseConfig extends YamlConfigWrapper {
|
||||
public abstract class BaseConfig extends LoadableYamlConfigWrapper {
|
||||
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
|
||||
@@ -2,10 +2,11 @@ package com.willfp.eco.core.config;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.wrapper.LoadableYamlConfigWrapper;
|
||||
import com.willfp.eco.core.config.wrapper.YamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ExtendableConfig extends YamlConfigWrapper {
|
||||
public abstract class ExtendableConfig extends LoadableYamlConfigWrapper {
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
* <p>
|
||||
|
||||
@@ -3,9 +3,10 @@ package com.willfp.eco.core.config;
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.wrapper.JSONConfigWrapper;
|
||||
import com.willfp.eco.core.config.wrapper.LoadableJSONConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class JsonStaticBaseConfig extends JSONConfigWrapper {
|
||||
public abstract class JsonStaticBaseConfig extends LoadableJSONConfigWrapper {
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.json, lang.json).
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.willfp.eco.core.config;
|
||||
|
||||
public interface LoadableJSONConfig extends JSONConfig, LoadableConfig {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.willfp.eco.core.config;
|
||||
|
||||
public interface LoadableYamlConfig extends Config, LoadableConfig {
|
||||
|
||||
}
|
||||
@@ -2,10 +2,11 @@ package com.willfp.eco.core.config;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.wrapper.LoadableYamlConfigWrapper;
|
||||
import com.willfp.eco.core.config.wrapper.YamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class StaticBaseConfig extends YamlConfigWrapper {
|
||||
public abstract class StaticBaseConfig extends LoadableYamlConfigWrapper {
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
* <p>
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public abstract class YamlConfig extends YamlConfigWrapper {
|
||||
public abstract class YamlConfig extends YamlConfigWrapper<Config> {
|
||||
/**
|
||||
* Config implementation for passing YamlConfigurations.
|
||||
* <p>
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.willfp.eco.core.config.wrapper;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.Config;
|
||||
import com.willfp.eco.core.config.JSONConfig;
|
||||
import com.willfp.eco.core.config.LoadableJSONConfig;
|
||||
import com.willfp.eco.core.config.LoadableYamlConfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -19,7 +21,7 @@ public interface ConfigFactory {
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
*/
|
||||
Config createUpdatableYamlConfig(@NotNull String configName,
|
||||
LoadableYamlConfig createUpdatableYamlConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source,
|
||||
@@ -34,7 +36,7 @@ public interface ConfigFactory {
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
JSONConfig createLoadableJSONConfig(@NotNull String configName,
|
||||
LoadableJSONConfig createLoadableJSONConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source);
|
||||
@@ -47,7 +49,7 @@ public interface ConfigFactory {
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
Config createLoadableYamlConfig(@NotNull String configName,
|
||||
LoadableYamlConfig createLoadableYamlConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source);
|
||||
|
||||
@@ -6,13 +6,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class JSONConfigWrapper extends ConfigWrapper<JSONConfig> implements JSONConfig {
|
||||
public abstract class JSONConfigWrapper<T extends JSONConfig> extends ConfigWrapper<T> implements JSONConfig {
|
||||
/**
|
||||
* Create a config wrapper.
|
||||
*
|
||||
* @param handle The handle.
|
||||
*/
|
||||
public JSONConfigWrapper(@NotNull final JSONConfig handle) {
|
||||
public JSONConfigWrapper(@NotNull final T handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.willfp.eco.core.config.wrapper;
|
||||
|
||||
import com.willfp.eco.core.config.LoadableConfig;
|
||||
import com.willfp.eco.core.config.LoadableJSONConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class LoadableJSONConfigWrapper extends JSONConfigWrapper<LoadableJSONConfig> implements LoadableConfig {
|
||||
/**
|
||||
* Create a config wrapper.
|
||||
*
|
||||
* @param handle The handle.
|
||||
*/
|
||||
public LoadableJSONConfigWrapper(@NotNull final LoadableJSONConfig handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createFile() {
|
||||
this.getHandle().createFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePath() {
|
||||
return this.getHandle().getResourcePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
this.getHandle().save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFile() {
|
||||
return this.getHandle().getConfigFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getHandle().getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.willfp.eco.core.config.wrapper;
|
||||
|
||||
import com.willfp.eco.core.config.LoadableConfig;
|
||||
import com.willfp.eco.core.config.LoadableYamlConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class LoadableYamlConfigWrapper extends YamlConfigWrapper<LoadableYamlConfig> implements LoadableConfig {
|
||||
/**
|
||||
* Create a config wrapper.
|
||||
*
|
||||
* @param handle The handle.
|
||||
*/
|
||||
public LoadableYamlConfigWrapper(@NotNull final LoadableYamlConfig handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createFile() {
|
||||
this.getHandle().createFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePath() {
|
||||
return this.getHandle().getResourcePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
this.getHandle().save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFile() {
|
||||
return this.getHandle().getConfigFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getHandle().getName();
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,13 @@ import com.willfp.eco.core.config.Config;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class YamlConfigWrapper extends ConfigWrapper<Config> implements WrappedBukkitConfig<YamlConfiguration> {
|
||||
public abstract class YamlConfigWrapper<T extends Config> extends ConfigWrapper<T> implements WrappedBukkitConfig<YamlConfiguration> {
|
||||
/**
|
||||
* Create a config wrapper.
|
||||
*
|
||||
* @param handle The handle.
|
||||
*/
|
||||
public YamlConfigWrapper(@NotNull final Config handle) {
|
||||
public YamlConfigWrapper(@NotNull final T handle) {
|
||||
super(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
|
||||
public class EcoConfigFactory implements ConfigFactory {
|
||||
@Override
|
||||
public Config createUpdatableYamlConfig(@NotNull final String configName,
|
||||
public com.willfp.eco.core.config.LoadableYamlConfig createUpdatableYamlConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final Class<?> source,
|
||||
@@ -33,7 +33,7 @@ public class EcoConfigFactory implements ConfigFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONConfig createLoadableJSONConfig(@NotNull final String configName,
|
||||
public com.willfp.eco.core.config.LoadableJSONConfig createLoadableJSONConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final Class<?> source) {
|
||||
@@ -46,7 +46,7 @@ public class EcoConfigFactory implements ConfigFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config createLoadableYamlConfig(@NotNull final String configName,
|
||||
public com.willfp.eco.core.config.LoadableYamlConfig createLoadableYamlConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final Class<?> source) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.willfp.eco.internal.config.json;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.LoadableConfig;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -18,7 +17,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class LoadableJSONConfig extends JSONConfigWrapper implements LoadableConfig {
|
||||
public class LoadableJSONConfig extends JSONConfigWrapper implements com.willfp.eco.core.config.LoadableJSONConfig {
|
||||
/**
|
||||
* The physical config file, as stored on disk.
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.willfp.eco.internal.config.yaml;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.LoadableConfig;
|
||||
import com.willfp.eco.core.config.wrapper.WrappedBukkitConfig;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
@@ -14,7 +13,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class LoadableYamlConfig extends YamlConfigWrapper<YamlConfiguration> implements LoadableConfig, WrappedBukkitConfig<YamlConfiguration> {
|
||||
public class LoadableYamlConfig extends YamlConfigWrapper<YamlConfiguration> implements com.willfp.eco.core.config.LoadableYamlConfig, WrappedBukkitConfig<YamlConfiguration> {
|
||||
/**
|
||||
* The physical config file, as stored on disk.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user