add missing synchronized blocks

This commit is contained in:
Leijurv 2018-11-28 18:21:27 -08:00
parent 043d6ffd20
commit 6f7729e34e
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -280,11 +280,13 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
} }
public void softCancelIfSafe() { public void softCancelIfSafe() {
if (!isSafeToCancel()) { synchronized (pathPlanLock) {
return; if (!isSafeToCancel()) {
return;
}
current = null;
next = null;
} }
current = null;
next = null;
cancelRequested = true; cancelRequested = true;
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours
// do everything BUT clear keys // do everything BUT clear keys
@ -293,8 +295,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
// just cancel the current path // just cancel the current path
public void secretInternalSegmentCancel() { public void secretInternalSegmentCancel() {
queuePathEvent(PathEvent.CANCELED); queuePathEvent(PathEvent.CANCELED);
current = null; synchronized (pathPlanLock) {
next = null; current = null;
next = null;
}
baritone.getInputOverrideHandler().clearAllKeys(); baritone.getInputOverrideHandler().clearAllKeys();
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock(); baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock();
@ -334,7 +338,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
} }
public void secretCursedFunctionDoNotCall(IPath path) { public void secretCursedFunctionDoNotCall(IPath path) {
current = new PathExecutor(this, path); synchronized (pathPlanLock) {
current = new PathExecutor(this, path);
}
} }
/** /**