use of com.sk89q.worldedit.session.SessionOwner in project FastAsyncWorldEdit by IntellectualSites.
the class ExpressionMaskParser method parseFromInput.
@Override
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
if (!input.startsWith("=")) {
return null;
}
// FAWE start - richer parsing
if (input.charAt(1) == '[') {
int end = input.lastIndexOf(']');
if (end == -1) {
return null;
}
input = input.substring(2, end);
} else {
input = input.substring(1);
}
try {
// FAWE start - richer parsing
Expression exp = Expression.compile(input, "x", "y", "z");
// FAWE end
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(context.requireExtent(), Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
if (context.getActor() != null) {
SessionOwner owner = context.getActor();
IntSupplier timeout = () -> WorldEdit.getInstance().getSessionManager().get(owner).getTimeout();
return new ExpressionMask(exp, timeout);
}
return new ExpressionMask(exp);
} catch (ExpressionException e) {
throw new InputParseException(Caption.of("worldedit.error.parser.invalid-expression", TextComponent.of(e.getMessage())));
}
}
Aggregations