Class ExpressionRegistry

java.lang.Object
net.citizensnpcs.api.ai.tree.expr.ExpressionRegistry

public class ExpressionRegistry extends Object
Registry for expression engines and parser for expression syntax. Supports syntax
  • `expression` - default engine (molang)
  • js`expression` - javascript engine
  • Constructor Details

    • ExpressionRegistry

      public ExpressionRegistry()
  • Method Details

    • compile

      Parses and compiles an expression string. Supports syntax
      • `expression` - default engine (molang)
      • js`expression` - javascript engine
      Parameters:
      expr - the expression string (including `...` wrapper)
      Returns:
      the compiled expression
      Throws:
      ExpressionEngine.ExpressionCompileException
    • getDefaultEngineName

      public String getDefaultEngineName()
      Gets the default engine name.
    • getEngine

      public ExpressionEngine getEngine(String name)
      Gets an engine by name.
      Parameters:
      name - the engine name
      Returns:
      the engine, or null if not found
    • isPossiblyExpression

      public boolean isPossiblyExpression(String value)
      Checks if a string is possibly a valid expression.
    • parseValue

      public ExpressionRegistry.ExpressionValue parseValue(String expr)
      Parses a value that might be an expression or a literal. If it's an expression, compiles and returns a ValueHolder that evaluates it. If it's a literal, returns a ValueHolder that returns the literal.
      Parameters:
      expr - the value string
      Returns:
      a ValueHolder for the value
    • registerEngine

      public void registerEngine(ExpressionEngine engine)
      Registers an expression engine.
      Parameters:
      engine - the engine to register
    • setDefaultEngine

      public void setDefaultEngine(String language)
      Sets the default language to use when no prefix is specified.