Skip to content

Commit 6473b9d

Browse files
Revert "Improve cancelling calculation"
This reverts commit 4a4b4c5.
1 parent 4a4b4c5 commit 6473b9d

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

server/src/main/java/com/soulfiremc/server/pathfinding/execution/PathExecutor.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public static CompletableFuture<Void> executePathfinding(BotConnection bot, Goal
6363
var dataManager = bot.dataManager();
6464
var clientEntity = dataManager.clientEntity();
6565

66-
var pathCompletionFuture = new CompletableFuture<Void>();
67-
6866
Boolean2ObjectFunction<List<WorldAction>> findPath =
6967
requiresRepositioning -> {
7068
var level = dataManager.currentLevel()
@@ -80,21 +78,14 @@ public static CompletableFuture<Void> executePathfinding(BotConnection bot, Goal
8078
logger.info("Starting calculations at: {}", start.formatXYZ());
8179
var actionsFuture = routeFinder.findRouteFuture(NodeState.forInfo(start, inventory), requiresRepositioning);
8280
bot.shutdownHooks().add(() -> actionsFuture.cancel(true));
83-
while (!actionsFuture.isDone()) {
84-
if (pathCompletionFuture.isDone()) {
85-
actionsFuture.cancel(true);
86-
return List.of();
87-
}
88-
89-
TimeUtil.waitTime(1, TimeUnit.MILLISECONDS);
90-
}
91-
9281
var actions = actionsFuture.join();
9382
logger.info("Calculated path with {} actions: {}", actions.size(), actions);
9483

9584
return actions;
9685
};
9786

87+
var pathCompletionFuture = new CompletableFuture<Void>();
88+
9889
// Cancel the path if the bot is disconnected
9990
bot.shutdownHooks().add(() -> pathCompletionFuture.cancel(true));
10091

0 commit comments

Comments
 (0)