From 2f00aa77508d8f47c0588815baabd0c7617e2d7a Mon Sep 17 00:00:00 2001 From: NEZNAMY Date: Sun, 10 Nov 2024 18:24:12 +0100 Subject: [PATCH] [Conditions] Fix mistake from past commits not loading true/false values if not wrapped in "" --- .../tab/shared/config/file/ConfigurationSection.java | 12 ++++++++++-- .../placeholders/conditions/ConditionsSection.java | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/shared/src/main/java/me/neznamy/tab/shared/config/file/ConfigurationSection.java b/shared/src/main/java/me/neznamy/tab/shared/config/file/ConfigurationSection.java index 6f832ab45..e31bfce10 100644 --- a/shared/src/main/java/me/neznamy/tab/shared/config/file/ConfigurationSection.java +++ b/shared/src/main/java/me/neznamy/tab/shared/config/file/ConfigurationSection.java @@ -104,7 +104,7 @@ public Object getObject(@NotNull String path, @NotNull Object defaultValue) { @Nullable private T getNullable(@NotNull String path, @NotNull Class clazz) { - return evaluateNullable(map.get(path), path, clazz); + return evaluateNullable(get(path), path, clazz); } @Nullable @@ -119,7 +119,7 @@ private T evaluateNullable(@Nullable Object value, @NotNull String path, @No @NotNull private T getRequired(@NotNull String path, @NotNull T defaultValue, @NotNull Class clazz) { - return evaluateRequired(map.get(path), path, defaultValue, clazz); + return evaluateRequired(get(path), path, defaultValue, clazz); } @NotNull @@ -137,6 +137,14 @@ private T evaluateRequired(@Nullable Object value, @NotNull String path, @No return (T) value; } + @Nullable + private Object get(@NotNull String key) { + for (Map.Entry entry : map.entrySet()) { + if (key.equalsIgnoreCase(entry.getKey().toString())) return entry.getValue(); + } + return null; + } + @NotNull public Collection getKeys() { return map.keySet(); diff --git a/shared/src/main/java/me/neznamy/tab/shared/placeholders/conditions/ConditionsSection.java b/shared/src/main/java/me/neznamy/tab/shared/placeholders/conditions/ConditionsSection.java index 4f000c413..492b4f7db 100644 --- a/shared/src/main/java/me/neznamy/tab/shared/placeholders/conditions/ConditionsSection.java +++ b/shared/src/main/java/me/neznamy/tab/shared/placeholders/conditions/ConditionsSection.java @@ -66,14 +66,14 @@ public static ConditionDefinition fromSection(@NotNull ConfigurationSection sect list = Collections.emptyList(); } String type = section.getString("type"); - String yes = section.getString("true"); + Object yes = section.getObject("true"); if (yes == null) yes = "true"; - String no = section.getString("false"); + Object no = section.getObject("false"); if (no == null) no = "false"; if (list.size() >= 2 && type == null) { section.startupWarn(String.format("Condition \"%s\" has multiple conditions defined, but is missing \"type\" attribute. Using AND.", name)); } - return new ConditionDefinition(list, !"OR".equals(type), yes, no); + return new ConditionDefinition(list, !"OR".equals(type), yes.toString(), no.toString()); } } }