From bf848c9f26a291ac9b2f449a363778a400f1b81e Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 16 Nov 2021 19:57:10 +0100 Subject: [PATCH] :bug: Fixed list values return a list instead of an array --- build.gradle | 2 +- .../skriptstorage/core/elements/NodeValue.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index b255d35..535c98f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'info.itsthesky' -version = '1.1.0' +version = '1.2.1' repositories { mavenCentral() diff --git a/src/main/java/info/itsthesky/skriptstorage/core/elements/NodeValue.java b/src/main/java/info/itsthesky/skriptstorage/core/elements/NodeValue.java index 7f2fb57..b834044 100644 --- a/src/main/java/info/itsthesky/skriptstorage/core/elements/NodeValue.java +++ b/src/main/java/info/itsthesky/skriptstorage/core/elements/NodeValue.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.function.Consumer; @Name("Node Value") @@ -51,8 +52,8 @@ public class NodeValue extends SimpleExpression { NodeValue.class, Object.class, ExpressionType.COMBINED, - "[storage] [the] [(1¦default)] value[s] %string% (of|from|in) [the] [(file|shortcut)] %string% [(2¦as (array|list))]", - "[storage] [the] [(file|shortcut)] %string%'[s] [(1¦default)] value[s] %string% [(2¦as (array|list))]" + "[storage] [the] [(1¦default)] value[(3¦s)] %string% (of|from|in) [the] [(file|shortcut)] %string% [(2¦as (array|list))]", + "[storage] [the] [(file|shortcut)] %string%'[s] [(1¦default)] value[(3¦s)] %string% [(2¦as (array|list))]" ); } @@ -60,6 +61,7 @@ public class NodeValue extends SimpleExpression { private Expression exprFile; private boolean changeDefault; private boolean forceList; + private boolean list; private Node node; @Nullable @@ -72,6 +74,9 @@ protected Object[] get(@NotNull Event e) { final FlatFile data = Utils.parse(path); if (data == null) return new Object[0]; + final Object entity = data.get(key); + if (entity instanceof List) + return ((List) entity).toArray(new Object[0]); return new Object[] {data.get(key)}; } @@ -133,7 +138,7 @@ public void change(@NotNull Event e, @Nullable Object[] values, Changer.@NotNull @Override public boolean isSingle() { - return true; + return !list; } @Override @@ -152,6 +157,7 @@ public boolean init(Expression @NotNull [] exprs, int matchedPattern, @NotNul exprFile = (Expression) exprs[1]; changeDefault = (parseResult.mark & 1) != 0; forceList = (parseResult.mark & 2) != 0; + list = (parseResult.mark & 3) != 0; node = SkriptLogger.getNode(); return true; }