// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java
// public class SkriptUtil {
//   @SuppressWarnings("unchecked")
//   public static <T> Expression<T> defendExpression(Expression<?> expr) {
//     if (expr instanceof UnparsedLiteral) {
//       Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class);
//       return (Expression<T>) (parsed == null ? expr : parsed);
//     } else if (expr instanceof ExpressionList) {
//       Expression[] exprs = ((ExpressionList) expr).getExpressions();
//       for (int i = 0; i < exprs.length; i++) {
//         exprs[i] = defendExpression(exprs[i]);
//       }
//     }
//     return (Expression<T>) expr;
//   }
// 
//   public static boolean hasUnparsedLiteral(Expression<?> expr) {
//     return expr instanceof UnparsedLiteral ||
//         (expr instanceof ExpressionList &&
//             Arrays.stream(((ExpressionList) expr).getExpressions())
//                 .anyMatch(UnparsedLiteral.class::isInstance));
//   }
// 
//   public static boolean canInitSafely(Expression<?>... expressions) {
//     return Arrays.stream(expressions)
//         .filter(Objects::nonNull)
//         .noneMatch(SkriptUtil::hasUnparsedLiteral);
//   }
// 
//   public static List<TriggerItem> getItemsFromNode(SectionNode node) {
//     RetainingLogHandler log = SkriptLogger.startRetainingLog();
//     try {
//       return ScriptLoader.loadItems(node);
//     } finally {
//       SkriptReflection.printLog(log);
//       ScriptLoader.deleteCurrentEvent();
//     }
//   }
// 
//   public static void clearSectionNode(SectionNode node) {
//     List<Node> subNodes = new ArrayList<>();
//     node.forEach(subNodes::add);
//     subNodes.forEach(Node::remove);
//   }
// 
//   public static File getCurrentScript() {
//     Config currentScript = ScriptLoader.currentScript;
//     return currentScript == null ? null : currentScript.getFile();
//   }
// 
//   public static ClassInfo<?> getUserClassInfo(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
// 
//     ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst());
// 
//     if (ci == null) {
//       ci = Classes.getClassInfoFromUserInput(wordData.getFirst());
//     }
// 
//     if (ci == null) {
//       Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name));
//       return Classes.getExactClassInfo(Object.class);
//     }
// 
//     return ci;
//   }
// 
//   public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
//     ClassInfo<?> ci = getUserClassInfo(name);
// 
//     return new NonNullPair<>(ci, wordData.getSecond());
//   }
// 
//   public static String replaceUserInputPatterns(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
//     ClassInfo<?> ci = getUserClassInfo(name);
// 
//     return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond());
//   }
// 
//   public static Function<Expression, Object> unwrapWithEvent(Event e) {
//     return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e);
//   }
// }


import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import com.btk5h.skriptmirror.util.SkriptUtil;
import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom;


public class ExprRawExpression extends SimpleExpression<Expression> {
  static {
    Skript.registerExpression(ExprRawExpression.class, Expression.class, ExpressionType.COMBINED,
        "[the] raw %objects%");
  }

  private Expression<?> expr;

  @Override
  protected Expression[] get(Event e) {
    Expression<?> expr = this.expr;
    if (expr instanceof ExprExpression && e instanceof CustomSyntaxEvent) {
      expr = ((ExprExpression) expr).getExpression(e).getSource();
    }
    return new Expression[]{expr};
  }

  @Override
  public boolean isSingle() {
    return true;
  }

  @Override
  public Class<? extends Expression> getReturnType() {
    return Expression.class;
  }

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

  @Override
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
                      SkriptParser.ParseResult parseResult) {
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java
// public class SkriptUtil {
//   @SuppressWarnings("unchecked")
//   public static <T> Expression<T> defendExpression(Expression<?> expr) {
//     if (expr instanceof UnparsedLiteral) {
//       Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class);
//       return (Expression<T>) (parsed == null ? expr : parsed);
//     } else if (expr instanceof ExpressionList) {
//       Expression[] exprs = ((ExpressionList) expr).getExpressions();
//       for (int i = 0; i < exprs.length; i++) {
//         exprs[i] = defendExpression(exprs[i]);
//       }
//     }
//     return (Expression<T>) expr;
//   }
// 
//   public static boolean hasUnparsedLiteral(Expression<?> expr) {
//     return expr instanceof UnparsedLiteral ||
//         (expr instanceof ExpressionList &&
//             Arrays.stream(((ExpressionList) expr).getExpressions())
//                 .anyMatch(UnparsedLiteral.class::isInstance));
//   }
// 
//   public static boolean canInitSafely(Expression<?>... expressions) {
//     return Arrays.stream(expressions)
//         .filter(Objects::nonNull)
//         .noneMatch(SkriptUtil::hasUnparsedLiteral);
//   }
// 
//   public static List<TriggerItem> getItemsFromNode(SectionNode node) {
//     RetainingLogHandler log = SkriptLogger.startRetainingLog();
//     try {
//       return ScriptLoader.loadItems(node);
//     } finally {
//       SkriptReflection.printLog(log);
//       ScriptLoader.deleteCurrentEvent();
//     }
//   }
// 
//   public static void clearSectionNode(SectionNode node) {
//     List<Node> subNodes = new ArrayList<>();
//     node.forEach(subNodes::add);
//     subNodes.forEach(Node::remove);
//   }
// 
//   public static File getCurrentScript() {
//     Config currentScript = ScriptLoader.currentScript;
//     return currentScript == null ? null : currentScript.getFile();
//   }
// 
//   public static ClassInfo<?> getUserClassInfo(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
// 
//     ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst());
// 
//     if (ci == null) {
//       ci = Classes.getClassInfoFromUserInput(wordData.getFirst());
//     }
// 
//     if (ci == null) {
//       Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name));
//       return Classes.getExactClassInfo(Object.class);
//     }
// 
//     return ci;
//   }
// 
//   public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
//     ClassInfo<?> ci = getUserClassInfo(name);
// 
//     return new NonNullPair<>(ci, wordData.getSecond());
//   }
// 
//   public static String replaceUserInputPatterns(String name) {
//     NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name);
//     ClassInfo<?> ci = getUserClassInfo(name);
// 
//     return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond());
//   }
// 
//   public static Function<Expression, Object> unwrapWithEvent(Event e) {
//     return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e);
//   }
// }


// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import com.btk5h.skriptmirror.util.SkriptUtil;
import org.bukkit.event.Event;

package com.btk5h.skriptmirror.skript.custom;


public class ExprRawExpression extends SimpleExpression<Expression> {
  static {
    Skript.registerExpression(ExprRawExpression.class, Expression.class, ExpressionType.COMBINED,
        "[the] raw %objects%");
  }

  private Expression<?> expr;

  @Override
  protected Expression[] get(Event e) {
    Expression<?> expr = this.expr;
    if (expr instanceof ExprExpression && e instanceof CustomSyntaxEvent) {
      expr = ((ExprExpression) expr).getExpression(e).getSource();
    }
    return new Expression[]{expr};
  }

  @Override
  public boolean isSingle() {
    return true;
  }

  @Override
  public Class<? extends Expression> getReturnType() {
    return Expression.class;
  }

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

  @Override
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
                      SkriptParser.ParseResult parseResult) {
    expr = SkriptUtil.defendExpression(exprs[0]);