The config changes dont end

This commit is contained in:
Auxilor
2021-07-14 16:09:35 +02:00
committed by Auxilor
parent 91ba7cc475
commit 9fc5b78fa0
33 changed files with 169 additions and 166 deletions

View File

@@ -6,11 +6,10 @@ group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly 'org.apache.maven:maven-artifact:3.0.3'
compileOnly 'org.bstats:bstats-bukkit:1.7'
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.10.9'
compileOnly 'com.google.code.gson:gson:2.8.7'
}

View File

@@ -1,4 +1,4 @@
package com.willfp.eco.core.config;
package com.willfp.eco.core.config.interfaces;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -0,0 +1,29 @@
package com.willfp.eco.core.config.interfaces;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface JSONConfig extends Config {
/**
* Get a list of subsections from config.
*
* @param path The key to fetch the value from.
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
*/
@NotNull
List<JSONConfig> getSubsections(@NotNull String path);
/**
* Get a list of subsections from config.
*
* @param path The key to fetch the value from.
* @return The found value, or null if not found.
*/
@Nullable
List<JSONConfig> getSubsectionsOrNull(@NotNull String path);
@Override
JSONConfig clone();
}

View File

@@ -1,4 +1,4 @@
package com.willfp.eco.core.config;
package com.willfp.eco.core.config.interfaces;
import java.io.File;
import java.io.IOException;

View File

@@ -0,0 +1,12 @@
package com.willfp.eco.core.config.interfaces;
import org.bukkit.configuration.file.YamlConfiguration;
public interface WrappedYamlConfiguration {
/**
* Get the ConfigurationSection handle.
*
* @return The handle.
*/
YamlConfiguration getBukkitHandle();
}

View File

@@ -1,30 +1,20 @@
package com.willfp.eco.core.config.json;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.config.json.wrapper.JSONConfigWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
public interface JSONConfig extends Config {
public class JSONConfig extends JSONConfigWrapper {
/**
* Get a list of subsections from config.
* Config implementation for passing maps.
* <p>
* Does not automatically update.
*
* @param path The key to fetch the value from.
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
* @param values The map of values.
*/
@NotNull
List<JSONConfig> getSubsections(@NotNull String path);
/**
* Get a list of subsections from config.
*
* @param path The key to fetch the value from.
* @return The found value, or null if not found.
*/
@Nullable
List<JSONConfig> getSubsectionsOrNull(@NotNull String path);
@Override
JSONConfig clone();
public JSONConfig(@NotNull final Map<String, Object> values) {
super(Eco.getHandler().getConfigFactory().createJSONConfig(values));
}
}

View File

@@ -5,7 +5,7 @@ import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.json.wrapper.LoadableJSONConfigWrapper;
import org.jetbrains.annotations.NotNull;
public abstract class JsonStaticBaseConfig extends LoadableJSONConfigWrapper {
public abstract class JSONStaticBaseConfig extends LoadableJSONConfigWrapper {
/**
* Config implementation for configs present in the plugin's base directory (eg config.json, lang.json).
* <p>
@@ -14,7 +14,7 @@ public abstract class JsonStaticBaseConfig extends LoadableJSONConfigWrapper {
* @param configName The name of the config
* @param plugin The plugin.
*/
protected JsonStaticBaseConfig(@NotNull final String configName,
protected JSONStaticBaseConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin) {
super(Eco.getHandler().getConfigFactory().createLoadableJSONConfig(configName, plugin, "", plugin.getClass()));
}

View File

@@ -1,7 +0,0 @@
package com.willfp.eco.core.config.json;
import com.willfp.eco.core.config.LoadableConfig;
public interface LoadableJSONConfig extends JSONConfig, LoadableConfig {
}

View File

@@ -1,19 +1,19 @@
package com.willfp.eco.core.config.json.wrapper;
import com.willfp.eco.core.config.json.JSONConfig;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import com.willfp.eco.core.config.wrapper.ConfigWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class JSONConfigWrapper<T extends JSONConfig> extends ConfigWrapper<T> implements JSONConfig {
public abstract class JSONConfigWrapper extends ConfigWrapper<JSONConfig> implements JSONConfig {
/**
* Create a config wrapper.
*
* @param handle The handle.
*/
public JSONConfigWrapper(@NotNull final T handle) {
protected JSONConfigWrapper(@NotNull final JSONConfig handle) {
super(handle);
}

View File

@@ -1,45 +1,48 @@
package com.willfp.eco.core.config.json.wrapper;
import com.willfp.eco.core.config.LoadableConfig;
import com.willfp.eco.core.config.json.LoadableJSONConfig;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
public abstract class LoadableJSONConfigWrapper extends JSONConfigWrapper<LoadableJSONConfig> implements LoadableConfig {
public abstract class LoadableJSONConfigWrapper extends JSONConfigWrapper implements LoadableConfig {
/**
* Create a config wrapper.
*
* @param handle The handle.
*/
public LoadableJSONConfigWrapper(@NotNull final LoadableJSONConfig handle) {
protected LoadableJSONConfigWrapper(@NotNull final JSONConfig handle) {
super(handle);
Validate.isTrue(handle instanceof LoadableConfig, "Wrapped config must be loadable!");
}
@Override
public void createFile() {
this.getHandle().createFile();
((LoadableConfig) this.getHandle()).createFile();
}
@Override
public String getResourcePath() {
return this.getHandle().getResourcePath();
return ((LoadableConfig) this.getHandle()).getResourcePath();
}
@Override
public void save() throws IOException {
this.getHandle().save();
((LoadableConfig) this.getHandle()).save();
}
@Override
public File getConfigFile() {
return this.getHandle().getConfigFile();
return ((LoadableConfig) this.getHandle()).getConfigFile();
}
@Override
public String getName() {
return this.getHandle().getName();
return ((LoadableConfig) this.getHandle()).getName();
}
}

View File

@@ -1,6 +1,6 @@
package com.willfp.eco.core.config.updating;
import com.willfp.eco.core.config.LoadableConfig;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import org.jetbrains.annotations.NotNull;
public interface ConfigHandler {

View File

@@ -1,10 +1,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.json.JSONConfig;
import com.willfp.eco.core.config.json.LoadableJSONConfig;
import com.willfp.eco.core.config.yaml.LoadableYamlConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -21,7 +19,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.
*/
LoadableYamlConfig createUpdatableYamlConfig(@NotNull String configName,
Config createUpdatableYamlConfig(@NotNull String configName,
@NotNull EcoPlugin plugin,
@NotNull String subDirectoryPath,
@NotNull Class<?> source,
@@ -36,7 +34,7 @@ public interface ConfigFactory {
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
*/
LoadableJSONConfig createLoadableJSONConfig(@NotNull String configName,
JSONConfig createLoadableJSONConfig(@NotNull String configName,
@NotNull EcoPlugin plugin,
@NotNull String subDirectoryPath,
@NotNull Class<?> source);
@@ -49,7 +47,7 @@ public interface ConfigFactory {
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
*/
LoadableYamlConfig createLoadableYamlConfig(@NotNull String configName,
Config createLoadableYamlConfig(@NotNull String configName,
@NotNull EcoPlugin plugin,
@NotNull String subDirectoryPath,
@NotNull Class<?> source);

View File

@@ -1,6 +1,6 @@
package com.willfp.eco.core.config.wrapper;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.interfaces.Config;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -1,8 +0,0 @@
package com.willfp.eco.core.config.yaml;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.LoadableConfig;
public interface LoadableYamlConfig extends Config, LoadableConfig {
}

View File

@@ -6,7 +6,6 @@ import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
import org.jetbrains.annotations.NotNull;
public abstract class YamlBaseConfig extends LoadableYamlConfigWrapper {
/**
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
* <p>

View File

@@ -1,14 +1,13 @@
package com.willfp.eco.core.config.yaml;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.yaml.wrapper.YamlConfigWrapper;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import java.io.StringReader;
public class YamlConfig extends YamlConfigWrapper<Config> {
public class YamlConfig extends YamlConfigWrapper {
/**
* Config implementation for passing YamlConfigurations.
* <p>

View File

@@ -1,45 +1,48 @@
package com.willfp.eco.core.config.yaml.wrapper;
import com.willfp.eco.core.config.LoadableConfig;
import com.willfp.eco.core.config.yaml.LoadableYamlConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
public abstract class LoadableYamlConfigWrapper extends YamlConfigWrapper<LoadableYamlConfig> implements LoadableConfig {
public abstract class LoadableYamlConfigWrapper extends YamlConfigWrapper implements LoadableConfig {
/**
* Create a config wrapper.
*
* @param handle The handle.
*/
public LoadableYamlConfigWrapper(@NotNull final LoadableYamlConfig handle) {
protected LoadableYamlConfigWrapper(@NotNull final Config handle) {
super(handle);
Validate.isTrue(handle instanceof LoadableConfig, "Wrapped config must be loadable!");
}
@Override
public void createFile() {
this.getHandle().createFile();
((LoadableConfig) this.getHandle()).createFile();
}
@Override
public String getResourcePath() {
return this.getHandle().getResourcePath();
return ((LoadableConfig) this.getHandle()).getResourcePath();
}
@Override
public void save() throws IOException {
this.getHandle().save();
((LoadableConfig) this.getHandle()).save();
}
@Override
public File getConfigFile() {
return this.getHandle().getConfigFile();
return ((LoadableConfig) this.getHandle()).getConfigFile();
}
@Override
public String getName() {
return this.getHandle().getName();
return ((LoadableConfig) this.getHandle()).getName();
}
}

View File

@@ -1,12 +0,0 @@
package com.willfp.eco.core.config.yaml.wrapper;
import org.bukkit.configuration.ConfigurationSection;
public interface WrappedYamlBukkitConfig<T extends ConfigurationSection> {
/**
* Get the ConfigurationSection handle.
*
* @return The handle.
*/
T getBukkitHandle();
}

View File

@@ -1,23 +1,24 @@
package com.willfp.eco.core.config.yaml.wrapper;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration;
import com.willfp.eco.core.config.wrapper.ConfigWrapper;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
public abstract class YamlConfigWrapper<T extends Config> extends ConfigWrapper<T> implements WrappedYamlBukkitConfig<YamlConfiguration> {
public abstract class YamlConfigWrapper extends ConfigWrapper<Config> implements WrappedYamlConfiguration {
/**
* Create a config wrapper.
*
* @param handle The handle.
*/
public YamlConfigWrapper(@NotNull final T handle) {
protected YamlConfigWrapper(@NotNull final Config handle) {
super(handle);
}
@Override
public YamlConfiguration getBukkitHandle() {
return (YamlConfiguration) ((WrappedYamlBukkitConfig<?>) this.getHandle()).getBukkitHandle();
return ((WrappedYamlConfiguration) this.getHandle()).getBukkitHandle();
}
}

View File

@@ -2,10 +2,10 @@ package com.willfp.eco.core.data;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.json.JSONConfig;
import com.willfp.eco.core.config.json.JsonStaticBaseConfig;
import com.willfp.eco.core.config.LoadableConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import com.willfp.eco.core.config.json.JSONStaticBaseConfig;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import lombok.experimental.UtilityClass;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.ApiStatus;
@@ -34,7 +34,7 @@ public class Data {
* @param config data.json.
*/
@ApiStatus.Internal
public void init(@NotNull final JsonStaticBaseConfig config) {
public void init(@NotNull final JSONStaticBaseConfig config) {
datafile = config;
}

View File

@@ -2,5 +2,6 @@ group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.10.9'
}

View File

@@ -1,14 +1,14 @@
package com.willfp.eco.internal.config;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.json.JSONConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import com.willfp.eco.core.config.wrapper.ConfigFactory;
import com.willfp.eco.internal.config.json.JSONConfigSection;
import com.willfp.eco.internal.config.json.LoadableJSONConfig;
import com.willfp.eco.internal.config.yaml.LoadableYamlConfig;
import com.willfp.eco.internal.config.yaml.UpdatableYamlConfig;
import com.willfp.eco.internal.config.yaml.YamlConfigSection;
import com.willfp.eco.internal.config.json.EcoJSONConfigSection;
import com.willfp.eco.internal.config.json.EcoLoadableJSONConfig;
import com.willfp.eco.internal.config.yaml.EcoLoadableYamlConfig;
import com.willfp.eco.internal.config.yaml.EcoUpdatableYamlConfig;
import com.willfp.eco.internal.config.yaml.EcoYamlConfigSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -16,13 +16,13 @@ import java.util.Map;
public class EcoConfigFactory implements ConfigFactory {
@Override
public com.willfp.eco.core.config.yaml.LoadableYamlConfig createUpdatableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source,
final boolean removeUnused,
@NotNull final String... updateBlacklist) {
return new UpdatableYamlConfig(
public Config createUpdatableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source,
final boolean removeUnused,
@NotNull final String... updateBlacklist) {
return new EcoUpdatableYamlConfig(
configName,
plugin,
subDirectoryPath,
@@ -33,11 +33,11 @@ public class EcoConfigFactory implements ConfigFactory {
}
@Override
public com.willfp.eco.core.config.json.LoadableJSONConfig createLoadableJSONConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
return new LoadableJSONConfig(
public JSONConfig createLoadableJSONConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
return new EcoLoadableJSONConfig(
configName,
plugin,
subDirectoryPath,
@@ -46,11 +46,11 @@ public class EcoConfigFactory implements ConfigFactory {
}
@Override
public com.willfp.eco.core.config.yaml.LoadableYamlConfig createLoadableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
return new LoadableYamlConfig(
public Config createLoadableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
return new EcoLoadableYamlConfig(
configName,
plugin,
subDirectoryPath,
@@ -60,11 +60,11 @@ public class EcoConfigFactory implements ConfigFactory {
@Override
public Config createYamlConfig(@NotNull final YamlConfiguration config) {
return new YamlConfigSection(config);
return new EcoYamlConfigSection(config);
}
@Override
public JSONConfig createJSONConfig(@NotNull final Map<String, Object> values) {
return new JSONConfigSection(values);
return new EcoJSONConfigSection(values);
}
}

View File

@@ -4,13 +4,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class JSONConfigSection extends JSONConfigWrapper {
public class EcoJSONConfigSection extends EcoJSONConfigWrapper {
/**
* Config section.
*
* @param values The values.
*/
public JSONConfigSection(@NotNull final Map<String, Object> values) {
public EcoJSONConfigSection(@NotNull final Map<String, Object> values) {
this.init(values);
}
}

View File

@@ -2,8 +2,8 @@ package com.willfp.eco.internal.config.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.json.JSONConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.JSONConfig;
import com.willfp.eco.util.StringUtils;
import lombok.Getter;
import org.apache.commons.lang.Validate;
@@ -20,7 +20,7 @@ import java.util.Objects;
import java.util.Set;
@SuppressWarnings({"unchecked", "unused"})
public class JSONConfigWrapper implements JSONConfig {
public class EcoJSONConfigWrapper implements JSONConfig {
/**
* The linked {@link ConfigurationSection} where values are physically stored.
*/
@@ -42,7 +42,7 @@ public class JSONConfigWrapper implements JSONConfig {
/**
* Abstract config.
*/
public JSONConfigWrapper() {
public EcoJSONConfigWrapper() {
}
@@ -88,7 +88,7 @@ public class JSONConfigWrapper implements JSONConfig {
}
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
EcoJSONConfigSection section = new EcoJSONConfigSection((Map<String, Object>) values.get(closestPath));
return section.getOfKnownType(path.substring(closestPath.length() + 1), clazz, false);
} else {
if (values.containsKey(closestPath)) {
@@ -115,7 +115,7 @@ public class JSONConfigWrapper implements JSONConfig {
list.add(root + key);
if (values.get(key) instanceof Map) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(key));
EcoJSONConfigSection section = new EcoJSONConfigSection((Map<String, Object>) values.get(key));
list.addAll(section.getDeepKeys(list, root + key + "."));
}
}
@@ -147,14 +147,14 @@ public class JSONConfigWrapper implements JSONConfig {
}
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
EcoJSONConfigSection section = new EcoJSONConfigSection((Map<String, Object>) values.get(closestPath));
section.setRecursively(path.substring(closestPath.length() + 1), object, false);
values.put(closestPath, section.getValues());
} else {
Object obj = object;
if (object instanceof JSONConfig) {
obj = ((JSONConfigWrapper) object).getValues();
obj = ((EcoJSONConfigWrapper) object).getValues();
}
values.put(path, obj);
@@ -174,7 +174,7 @@ public class JSONConfigWrapper implements JSONConfig {
public Config getSubsectionOrNull(@NotNull final String path) {
if (values.containsKey(path)) {
Map<String, Object> subsection = (Map<String, Object>) values.get(path);
return new JSONConfigSection(subsection);
return new EcoJSONConfigSection(subsection);
} else {
return null;
}
@@ -200,7 +200,7 @@ public class JSONConfigWrapper implements JSONConfig {
List<JSONConfig> configs = new ArrayList<>();
for (Map<String, Object> map : maps) {
configs.add(new JSONConfigSection(map));
configs.add(new EcoJSONConfigSection(map));
}
return configs;
@@ -349,6 +349,6 @@ public class JSONConfigWrapper implements JSONConfig {
@Override
public JSONConfig clone() {
return new JSONConfigSection(new HashMap<>(this.getValues()));
return new EcoJSONConfigSection(new HashMap<>(this.getValues()));
}
}

View File

@@ -1,6 +1,7 @@
package com.willfp.eco.internal.config.json;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import lombok.AccessLevel;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
@@ -17,7 +18,7 @@ import java.nio.file.StandardOpenOption;
import java.util.HashMap;
@SuppressWarnings({"unchecked", "unused"})
public class LoadableJSONConfig extends JSONConfigWrapper implements com.willfp.eco.core.config.json.LoadableJSONConfig {
public class EcoLoadableJSONConfig extends EcoJSONConfigWrapper implements LoadableConfig {
/**
* The physical config file, as stored on disk.
*/
@@ -56,10 +57,10 @@ public class LoadableJSONConfig extends JSONConfigWrapper implements com.willfp.
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
*/
public LoadableJSONConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
public EcoLoadableJSONConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {
this.plugin = plugin;
this.name = configName + ".json";
this.source = source;

View File

@@ -4,10 +4,10 @@ import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.config.updating.ConfigHandler;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.eco.core.config.LoadableConfig;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdatableClassException;
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
import com.willfp.eco.internal.config.yaml.UpdatableYamlConfig;
import com.willfp.eco.internal.config.yaml.EcoUpdatableYamlConfig;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -100,7 +100,7 @@ public class EcoConfigHandler extends PluginDependent<EcoPlugin> implements Conf
@Override
public void updateConfigs() {
for (LoadableConfig config : configs) {
if (config instanceof UpdatableYamlConfig updatableYamlConfig) {
if (config instanceof EcoUpdatableYamlConfig updatableYamlConfig) {
updatableYamlConfig.update();
}
}

View File

@@ -1,7 +1,8 @@
package com.willfp.eco.internal.config.yaml;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.yaml.wrapper.WrappedYamlBukkitConfig;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -13,7 +14,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class LoadableYamlConfig extends YamlConfigWrapper<YamlConfiguration> implements com.willfp.eco.core.config.yaml.LoadableYamlConfig, WrappedYamlBukkitConfig<YamlConfiguration> {
public class EcoLoadableYamlConfig extends EcoYamlConfigWrapper<YamlConfiguration> implements WrappedYamlConfiguration, LoadableConfig {
/**
* The physical config file, as stored on disk.
*/
@@ -52,7 +53,7 @@ public class LoadableYamlConfig extends YamlConfigWrapper<YamlConfiguration> imp
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
*/
public LoadableYamlConfig(@NotNull final String configName,
public EcoLoadableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source) {

View File

@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class UpdatableYamlConfig extends LoadableYamlConfig {
public class EcoUpdatableYamlConfig extends EcoLoadableYamlConfig {
/**
* Whether keys not in the base config should be removed on update.
*/
@@ -35,7 +35,7 @@ public class UpdatableYamlConfig extends LoadableYamlConfig {
* @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.
*/
public UpdatableYamlConfig(@NotNull final String configName,
public EcoUpdatableYamlConfig(@NotNull final String configName,
@NotNull final EcoPlugin plugin,
@NotNull final String subDirectoryPath,
@NotNull final Class<?> source,

View File

@@ -3,13 +3,13 @@ package com.willfp.eco.internal.config.yaml;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
public class YamlConfigSection extends YamlConfigWrapper<ConfigurationSection> {
public class EcoYamlConfigSection extends EcoYamlConfigWrapper<ConfigurationSection> {
/**
* Config section.
*
* @param section The section.
*/
public YamlConfigSection(@NotNull final ConfigurationSection section) {
public EcoYamlConfigSection(@NotNull final ConfigurationSection section) {
this.init(section);
}
}

View File

@@ -1,7 +1,6 @@
package com.willfp.eco.internal.config.yaml;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.yaml.wrapper.WrappedYamlBukkitConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.util.StringUtils;
import lombok.Getter;
import org.apache.commons.lang.Validate;
@@ -18,7 +17,7 @@ import java.util.Map;
import java.util.Objects;
@SuppressWarnings({"unchecked", "unused"})
public class YamlConfigWrapper<T extends ConfigurationSection> implements Config, WrappedYamlBukkitConfig<T> {
public class EcoYamlConfigWrapper<T extends ConfigurationSection> implements Config {
/**
* The linked {@link ConfigurationSection} where values are physically stored.
*/
@@ -33,7 +32,7 @@ public class YamlConfigWrapper<T extends ConfigurationSection> implements Config
/**
* Abstract config.
*/
public YamlConfigWrapper() {
public EcoYamlConfigWrapper() {
}
@@ -98,7 +97,7 @@ public class YamlConfigWrapper<T extends ConfigurationSection> implements Config
if (raw == null) {
cache.put(path, null);
} else {
cache.put(path, new YamlConfigSection(raw));
cache.put(path, new EcoYamlConfigSection(raw));
}
return getSubsectionOrNull(path);
}
@@ -289,11 +288,6 @@ public class YamlConfigWrapper<T extends ConfigurationSection> implements Config
@Override
public Config clone() {
return new YamlConfigSection(YamlConfiguration.loadConfiguration(new StringReader(this.toPlaintext())));
}
@Override
public T getBukkitHandle() {
return handle;
return new EcoYamlConfigSection(YamlConfiguration.loadConfiguration(new StringReader(this.toPlaintext())));
}
}

View File

@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
@UtilityClass
public final class DropManager {
/**
* The currently used type, or implementation, of {@link AbstractDropQueue}.
* The currently used type, or implementation, of {@link com.willfp.eco.core.drops.DropQueue}.
* <p>
* Default is {@link DropQueueType#COLLATED}, however this can be changed.
*/

View File

@@ -5,7 +5,7 @@ dependencies {
implementation 'org.apache.maven:maven-artifact:3.0.3'
implementation 'org.bstats:bstats-bukkit:1.7'
compileOnly 'com.google.code.gson:gson:2.8.7'
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly project(":eco-core:core-proxy")
compileOnly project(":eco-core:core-backend")
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'

View File

@@ -1,10 +1,10 @@
package com.willfp.eco.spigot.config;
import com.willfp.eco.core.config.json.JsonStaticBaseConfig;
import com.willfp.eco.core.config.json.JSONStaticBaseConfig;
import com.willfp.eco.spigot.EcoSpigotPlugin;
import org.jetbrains.annotations.NotNull;
public class DataJson extends JsonStaticBaseConfig {
public class DataJson extends JSONStaticBaseConfig {
/**
* Init data.json.
*