Refactored configs

This commit is contained in:
Auxilor
2021-06-22 15:24:32 +01:00
parent f1b113f435
commit 5e9a408704
6 changed files with 18 additions and 18 deletions

View File

@@ -5,7 +5,7 @@ import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.JSONConfig;
import com.willfp.eco.core.config.JsonStaticBaseConfig;
import com.willfp.eco.internal.config.LoadableConfig;
import com.willfp.eco.internal.config.json.JSONConfigSection;
import com.willfp.eco.internal.config.json.JsonConfigSection;
import lombok.experimental.UtilityClass;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.ApiStatus;
@@ -74,7 +74,7 @@ public class Data {
if (config == null) {
config = (JSONConfig) datafile.getSubsectionOrNull("player-data." + plugin.getName().toLowerCase() + "." + player.getUniqueId());
if (config == null) {
config = new JSONConfigSection(new HashMap<>());
config = new JsonConfigSection(new HashMap<>());
}
PLAYER_DATA.get(player.getUniqueId()).put(plugin, config);
return getData(player, plugin);

View File

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

View File

@@ -20,7 +20,7 @@ import java.util.Objects;
import java.util.Set;
@SuppressWarnings({"unchecked", "unused"})
public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
public abstract class JsonConfigWrapper implements JSONConfig, Cloneable {
/**
* The linked {@link ConfigurationSection} where values are physically stored.
*/
@@ -42,7 +42,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
/**
* Abstract config.
*/
protected JSONConfigWrapper() {
protected JsonConfigWrapper() {
}
@@ -88,7 +88,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
}
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
JsonConfigSection section = new JsonConfigSection((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 abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
list.add(root + key);
if (values.get(key) instanceof Map) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(key));
JsonConfigSection section = new JsonConfigSection((Map<String, Object>) values.get(key));
list.addAll(section.getDeepKeys(list, root + key + "."));
}
}
@@ -147,14 +147,14 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
}
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
JsonConfigSection section = new JsonConfigSection((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 = ((JsonConfigWrapper) object).getValues();
}
values.put(path, obj);
@@ -174,7 +174,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
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 JsonConfigSection(subsection);
} else {
return null;
}
@@ -200,7 +200,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
List<JSONConfig> configs = new ArrayList<>();
for (Map<String, Object> map : maps) {
configs.add(new JSONConfigSection(map));
configs.add(new JsonConfigSection(map));
}
return configs;
@@ -339,7 +339,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
}
@Override
public JSONConfigWrapper clone() {
return new JSONConfigSection(new HashMap<>(this.getValues()));
public JsonConfigWrapper clone() {
return new JsonConfigSection(new HashMap<>(this.getValues()));
}
}

View File

@@ -18,7 +18,7 @@ import java.nio.file.StandardOpenOption;
import java.util.HashMap;
@SuppressWarnings({"unchecked", "unused"})
public abstract class LoadableJsonConfig extends JSONConfigWrapper implements LoadableConfig {
public abstract class LoadableJsonConfig extends JsonConfigWrapper implements LoadableConfig {
/**
* The physical config file, as stored on disk.
*/

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 ConfigSection extends YamlConfigWrapper<ConfigurationSection> {
public class YamlConfigSection extends YamlConfigWrapper<ConfigurationSection> {
/**
* Config section.
*
* @param section The section.
*/
public ConfigSection(@NotNull final ConfigurationSection section) {
public YamlConfigSection(@NotNull final ConfigurationSection section) {
this.init(section);
}
}

View File

@@ -96,7 +96,7 @@ public abstract class YamlConfigWrapper<T extends ConfigurationSection> implemen
if (raw == null) {
cache.put(path, null);
} else {
cache.put(path, new ConfigSection(raw));
cache.put(path, new YamlConfigSection(raw));
}
return getSubsectionOrNull(path);
}