package com.btk5h.skriptmirror.skript.custom;

import ch.njol.skript.ScriptLoader;
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.TriggerItem;
import ch.njol.skript.log.ErrorQuality;
import ch.njol.util.Kleenean;
import com.btk5h.skriptmirror.Util;
import org.bukkit.event.Event;

public class EffReturn extends Effect {
  static {
    Skript.registerEffect(EffReturn.class, "return %objects%");
  }

  public Expression<Object> objects;

  @Override
  protected void execute(Event e) {
    throw new UnsupportedOperationException();
  }

  @Override
  protected TriggerItem walk(Event e) {
    ((CustomExpression.ExpressionGetEvent) e).setOutput(objects.getAll(e));
    return null;
  }

  @Override
  public String toString(Event e, boolean debug) {
    return "return " + objects.toString(e, debug);
  }

  @SuppressWarnings("unchecked")
  @Override
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
                      SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(CustomExpression.ExpressionGetEvent.class)) {
      Skript.error("Return may only be used in custom expression getters.", ErrorQuality.SEMANTIC_ERROR);
      return false;
    }

    objects = Util.defendExpression(exprs[0]);

    return Util.canInitSafely(objects);
  }
}

@@ -505,17 +505,19 @@
 urn 
-%25
+%5B%25-
 objects%25
 %22);%0A
@@ -512,16 +512,17 @@
 objects%25
+%5D
 %22);%0A  %7D%0A
@@ -708,24 +708,53 @@
 (Event e) %7B%0A
+    if (objects != null) %7B%0A  
     ((Custom
@@ -817,16 +817,109 @@
 ll(e));%0A
+    %7D else %7B%0A      ((CustomExpression.ExpressionGetEvent) e).setOutput(new Object%5B0%5D);%0A    %7D%0A
     retu

Make return value optional for expressions