From fa8139f4b3327c078344419293e0159d91626f3e Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 5 Apr 2019 14:46:29 -0400 Subject: [PATCH] Transfer Request to evaluation thread for Expressions. --- .../worldedit/internal/expression/Expression.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index 944fd97d8..0e82a4750 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.internal.expression.runtime.Functions; import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.internal.expression.runtime.ReturnException; import com.sk89q.worldedit.internal.expression.runtime.Variable; +import com.sk89q.worldedit.session.request.Request; import java.util.HashMap; import java.util.List; @@ -142,7 +143,18 @@ public class Expression { } private double evaluateRootTimed(int timeout) throws EvaluationException { - Future result = evalThread.submit(this::evaluateRoot); + Request request = Request.request(); + Future result = evalThread.submit(() -> { + Request local = Request.request(); + local.setSession(request.getSession()); + local.setWorld(request.getWorld()); + local.setEditSession(request.getEditSession()); + try { + return Expression.this.evaluateRoot(); + } finally { + Request.reset(); + } + }); try { return result.get(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) {