Class ExpressionRegistry
java.lang.Object
net.citizensnpcs.api.ai.tree.expr.ExpressionRegistry
Registry for expression engines and parser for expression syntax.
Supports syntax
- `expression` - default engine (molang)
- js`expression` - javascript engine
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionParses and compiles an expression string.Gets the default engine name.Gets an engine by name.booleanisPossiblyExpression(String value) Checks if a string is possibly a valid expression.parseValue(String expr) Parses a value that might be an expression or a literal.voidregisterEngine(ExpressionEngine engine) Registers an expression engine.voidsetDefaultEngine(String language) Sets the default language to use when no prefix is specified.
-
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
Gets the default engine name. -
getEngine
Gets an engine by name.- Parameters:
name- the engine name- Returns:
- the engine, or null if not found
-
isPossiblyExpression
Checks if a string is possibly a valid expression. -
parseValue
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
Registers an expression engine.- Parameters:
engine- the engine to register
-
setDefaultEngine
Sets the default language to use when no prefix is specified.
-