From 6d3f2fc5dc1bd47d48cfe228e0b9d54460c7dfeb Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 18 Mar 2021 18:55:50 +0000 Subject: [PATCH] Improved consistency of config list getters --- .../eco/internal/config/AbstractUndefinedConfig.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eco-util/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java b/eco-util/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java index 77f098f1..476481db 100644 --- a/eco-util/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java +++ b/eco-util/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java @@ -10,6 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -150,7 +151,7 @@ public abstract class AbstractUndefinedConfig extends PluginDependent { if (cache.containsKey(path)) { return (List) cache.get(path); } else { - cache.put(path, config.getIntegerList(path)); + cache.put(path, has(path) ? new ArrayList<>(config.getIntegerList(path)) : new ArrayList<>()); return getInts(path); } } @@ -211,7 +212,7 @@ public abstract class AbstractUndefinedConfig extends PluginDependent { if (cache.containsKey(path)) { return (List) cache.get(path); } else { - cache.put(path, config.getBooleanList(path)); + cache.put(path, has(path) ? new ArrayList<>(config.getBooleanList(path)) : new ArrayList<>()); return getBools(path); } } @@ -273,7 +274,7 @@ public abstract class AbstractUndefinedConfig extends PluginDependent { if (cache.containsKey(path)) { return (List) cache.get(path); } else { - cache.put(path, config.getStringList(path)); + cache.put(path, has(path) ? new ArrayList<>(config.getStringList(path)) : new ArrayList<>()); return getStrings(path); } } @@ -334,7 +335,7 @@ public abstract class AbstractUndefinedConfig extends PluginDependent { if (cache.containsKey(path)) { return (List) cache.get(path); } else { - cache.put(path, config.getDoubleList(path)); + cache.put(path, has(path) ? new ArrayList<>(config.getDoubleList(path)) : new ArrayList<>()); return getDoubles(path); } }