Search in sources :

Example 1 with ExpressionPattern

use of com.fastasyncworldedit.core.function.pattern.ExpressionPattern in project FastAsyncWorldEdit by IntellectualSites.

the class ExpressionPatternParser method parseFromSimpleInput.

@Override
public Pattern parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
    try {
        Expression exp = Expression.compile(input.substring(1), "x", "y", "z");
        WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(context.requireExtent(), Vector3.ONE, Vector3.ZERO);
        exp.setEnvironment(env);
        return new ExpressionPattern(exp);
    } catch (ExpressionException e) {
        throw new InputParseException(Caption.of("worldedit.error.parser.invalid-expression", TextComponent.of(e.getMessage())));
    }
}
Also used : InputParseException(com.sk89q.worldedit.extension.input.InputParseException) WorldEditExpressionEnvironment(com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment) Expression(com.sk89q.worldedit.internal.expression.Expression) ExpressionPattern(com.fastasyncworldedit.core.function.pattern.ExpressionPattern) ExpressionException(com.sk89q.worldedit.internal.expression.ExpressionException)

Aggregations

ExpressionPattern (com.fastasyncworldedit.core.function.pattern.ExpressionPattern)1 InputParseException (com.sk89q.worldedit.extension.input.InputParseException)1 Expression (com.sk89q.worldedit.internal.expression.Expression)1 ExpressionException (com.sk89q.worldedit.internal.expression.ExpressionException)1 WorldEditExpressionEnvironment (com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment)1