From 36a9afdf4a0bac18e060a2dfdcc0931e6ba0e4c0 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Sat, 23 Nov 2024 08:18:45 +0000 Subject: [PATCH] Fix bits. --- .../ch/njol/skript/expressions/ExprResult.java | 16 +++++++--------- .../org/skriptlang/skript/util/Executable.java | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprResult.java b/src/main/java/ch/njol/skript/expressions/ExprResult.java index 09f90708c1c..2f6576b257c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprResult.java +++ b/src/main/java/ch/njol/skript/expressions/ExprResult.java @@ -19,7 +19,7 @@ @Name("Result (Experimental)") @Description({ "Runs something (like a function) and returns its result.", - "If the thing is expected to return multiple values, specify 'results'." + "If the thing is expected to return multiple values, use 'results' instead of 'result'." }) @Examples({ "set {_function} to the function named \"myFunction\"", @@ -29,7 +29,6 @@ }) @Since("INSERT VERSION") @Keywords({"run", "result", "execute", "function", "reflection"}) -@SuppressWarnings("NotNullFieldNotInitialized") public class ExprResult extends PropertyExpression, Object> { static { @@ -53,8 +52,8 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is if (hasArguments) { this.arguments = LiteralUtils.defendExpression(expressions[1]); Expression[] arguments; - if (this.arguments instanceof ExpressionList) - arguments = ((ExpressionList) this.arguments).getExpressions(); + if (this.arguments instanceof ExpressionList list) + arguments = list.getExpressions(); else arguments = new Expression[]{this.arguments}; this.input = new DynamicFunctionReference.Input(arguments); @@ -69,9 +68,8 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is protected Object[] get(Event event, Executable[] source) { for (Executable task : source) { Object[] arguments; - if (task instanceof DynamicFunctionReference) { - //noinspection rawtypes - DynamicFunctionReference reference = (DynamicFunctionReference) task; + //noinspection rawtypes + if (task instanceof DynamicFunctionReference reference) { Expression validated = reference.validate(input); if (validated == null) return new Object[0]; @@ -81,8 +79,8 @@ protected Object[] get(Event event, Executable[] source) { else arguments = new Object[0]; Object execute = task.execute(event, arguments); - if (execute instanceof Object[]) - return (Object[]) execute; + if (execute instanceof Object[] results) + return results; return new Object[]{execute}; } return new Object[0]; diff --git a/src/main/java/org/skriptlang/skript/util/Executable.java b/src/main/java/org/skriptlang/skript/util/Executable.java index 51ef5e37931..4ecb9f6c89b 100644 --- a/src/main/java/org/skriptlang/skript/util/Executable.java +++ b/src/main/java/org/skriptlang/skript/util/Executable.java @@ -5,8 +5,8 @@ * This is an abstraction for general triggers (runnables, tasks, functions, etc.) * without any Bukkit dependency. * - * @param The source type of this process. - * @param The result type of this process. + * @param The source type of this process (e.g. Event, CommandSender, etc.) + * @param The return type of this process. */ public interface Executable {