From 26adb393eb7ea78e8e104171e3751820c702f228 Mon Sep 17 00:00:00 2001 From: Pikachu920 <28607612+Pikachu920@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:50:45 -0600 Subject: [PATCH] Goodbye WrapperExpression --- .../skriptmirror/util/ClassInfoReference.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/btk5h/skriptmirror/util/ClassInfoReference.java b/src/main/java/com/btk5h/skriptmirror/util/ClassInfoReference.java index 98b7239..f931118 100644 --- a/src/main/java/com/btk5h/skriptmirror/util/ClassInfoReference.java +++ b/src/main/java/com/btk5h/skriptmirror/util/ClassInfoReference.java @@ -4,6 +4,7 @@ import ch.njol.skript.expressions.base.WrapperExpression; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import org.bukkit.event.Event; import org.eclipse.jdt.annotation.Nullable; @@ -49,7 +50,12 @@ public boolean isPlural() { public static Expression getFromClassInfoExpression(Expression> expression) { ClassInfoReference parsedReference = SkriptUtil.getClassInfoReference(expression); - return new WrapperExpression() { + return new SimpleExpression() { + + @Override + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + return expression.init(expressions, matchedPattern, isDelayed, parseResult); + } @Override protected ClassInfoReference[] get(Event event) { @@ -69,14 +75,22 @@ protected ClassInfoReference[] get(Event event) { } } + public Class getReturnType() { + return ClassInfoReference.class; + } + @Override - public String toString(@Nullable Event event, boolean debug) { - return expression.toString(event, debug); + public boolean isSingle() { + return expression.isSingle(); } + @Override - public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { - return expression.init(expressions, matchedPattern, isDelayed, parseResult); + public String toString(@Nullable Event event, boolean debug) { + if (debug) { + return expression.toString(event, true) + " (wrapped by ClassInfoReference)"; + } + return expression.toString(event, false); } };