From 6f7729e34ea68be69ff5fb4d178f6a0ad79ecfe8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 28 Nov 2018 18:21:27 -0800 Subject: [PATCH] add missing synchronized blocks --- .../baritone/behavior/PathingBehavior.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index c6c8042f..bd2146b8 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -280,11 +280,13 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public void softCancelIfSafe() { - if (!isSafeToCancel()) { - return; + synchronized (pathPlanLock) { + if (!isSafeToCancel()) { + return; + } + current = null; + next = null; } - current = null; - next = null; cancelRequested = true; getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours // do everything BUT clear keys @@ -293,8 +295,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // just cancel the current path public void secretInternalSegmentCancel() { queuePathEvent(PathEvent.CANCELED); - current = null; - next = null; + synchronized (pathPlanLock) { + current = null; + next = null; + } baritone.getInputOverrideHandler().clearAllKeys(); getInProgress().ifPresent(AbstractNodeCostSearch::cancel); baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock(); @@ -334,7 +338,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public void secretCursedFunctionDoNotCall(IPath path) { - current = new PathExecutor(this, path); + synchronized (pathPlanLock) { + current = new PathExecutor(this, path); + } } /**