Example #1
0
 @Override
 public boolean init(
     Expression<?>[] exprs,
     int matchedPattern,
     Kleenean isDelayed,
     SkriptParser.ParseResult parseResult) {
   first = exprs[0];
   second = exprs[1];
   match = matchedPattern;
   if (first instanceof Variable && second instanceof Variable) {
     first = first.getConvertedExpression(Object.class);
     second = second.getConvertedExpression(Object.class);
   } else if (first instanceof Literal<?> && second instanceof Literal<?>) {
     first = first.getConvertedExpression(Object.class);
     second = second.getConvertedExpression(Object.class);
     if (first == null || second == null) return false;
   } else {
     if (first instanceof Literal<?>) {
       first = first.getConvertedExpression(second.getReturnType());
       if (first == null) return false;
     } else if (second instanceof Literal<?>) {
       second = second.getConvertedExpression(first.getReturnType());
       if (second == null) return false;
     }
     if (first instanceof Variable) {
       first = first.getConvertedExpression(second.getReturnType());
     } else if (second instanceof Variable) {
       second = second.getConvertedExpression(first.getReturnType());
     }
     assert first != null && second != null;
   }
   return true;
 }