From 6473b9d176bb6d852e6b84e32492723a3e35ff6a Mon Sep 17 00:00:00 2001 From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:20:14 +0200 Subject: [PATCH] Revert "Improve cancelling calculation" This reverts commit 4a4b4c594a3f45b20a4fde6f2fddcee98c65280b. --- .../server/pathfinding/execution/PathExecutor.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/com/soulfiremc/server/pathfinding/execution/PathExecutor.java b/server/src/main/java/com/soulfiremc/server/pathfinding/execution/PathExecutor.java index 23008f4d3..a4f87ca5d 100644 --- a/server/src/main/java/com/soulfiremc/server/pathfinding/execution/PathExecutor.java +++ b/server/src/main/java/com/soulfiremc/server/pathfinding/execution/PathExecutor.java @@ -63,8 +63,6 @@ public static CompletableFuture executePathfinding(BotConnection bot, Goal var dataManager = bot.dataManager(); var clientEntity = dataManager.clientEntity(); - var pathCompletionFuture = new CompletableFuture(); - Boolean2ObjectFunction> findPath = requiresRepositioning -> { var level = dataManager.currentLevel() @@ -80,21 +78,14 @@ public static CompletableFuture executePathfinding(BotConnection bot, Goal logger.info("Starting calculations at: {}", start.formatXYZ()); var actionsFuture = routeFinder.findRouteFuture(NodeState.forInfo(start, inventory), requiresRepositioning); bot.shutdownHooks().add(() -> actionsFuture.cancel(true)); - while (!actionsFuture.isDone()) { - if (pathCompletionFuture.isDone()) { - actionsFuture.cancel(true); - return List.of(); - } - - TimeUtil.waitTime(1, TimeUnit.MILLISECONDS); - } - var actions = actionsFuture.join(); logger.info("Calculated path with {} actions: {}", actions.size(), actions); return actions; }; + var pathCompletionFuture = new CompletableFuture(); + // Cancel the path if the bot is disconnected bot.shutdownHooks().add(() -> pathCompletionFuture.cancel(true));