Class LiteralUtils

java.lang.Object
ch.njol.skript.util.LiteralUtils

public class LiteralUtils extends Object
A class that contains methods based around making it easier to deal with UnparsedLiteral objects.
  • Constructor Details

    • LiteralUtils

      public LiteralUtils()
  • Method Details

    • defendExpression

      public static <T> Expression<T> defendExpression(Expression<?> expr)
      Checks an Expression for UnparsedLiteral objects and converts them if found.
      Type Parameters:
      T - expr's type
      Parameters:
      expr - The expression to check for UnparsedLiteral objects
      Returns:
      expr without UnparsedLiteral objects
    • hasUnparsedLiteral

      public static boolean hasUnparsedLiteral(Expression<?> expr)
      Checks if an Expression contains UnparsedLiteral objects.
      Parameters:
      expr - The Expression to check for UnparsedLiteral objects
      Returns:
      Whether or not expr contains UnparsedLiteral objects
    • canInitSafely

      public static boolean canInitSafely(Expression<?>... expressions)
      Checks if the passed Expressions are non-null and do not contain UnparsedLiteral objects.
      Parameters:
      expressions - The expressions to check for UnparsedLiteral objects
      Returns:
      Whether or not the passed expressions contain UnparsedLiteral objects