From 80108127c3001088f06f3a0565f25890782e7261 Mon Sep 17 00:00:00 2001 From: hayanesuru Date: Wed, 23 Jul 2025 18:14:11 +0900 Subject: [PATCH] fix shutdown --- .../dreeam/leaf/async/ShutdownExecutors.java | 18 +++++++++--------- .../dreeam/leaf/async/locate/AsyncLocator.java | 5 ++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/leaf-server/src/main/java/org/dreeam/leaf/async/ShutdownExecutors.java b/leaf-server/src/main/java/org/dreeam/leaf/async/ShutdownExecutors.java index 86fb830e..d11ccdc8 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/async/ShutdownExecutors.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/async/ShutdownExecutors.java @@ -15,15 +15,6 @@ public class ShutdownExecutors { public static final Logger LOGGER = LogManager.getLogger("Leaf"); public static void shutdown(MinecraftServer server) { - if (AsyncLocator.LOCATING_EXECUTOR_SERVICE != null) { - LOGGER.info("Waiting for structure locating executor to shutdown..."); - AsyncLocator.LOCATING_EXECUTOR_SERVICE.shutdown(); - try { - AsyncLocator.LOCATING_EXECUTOR_SERVICE.awaitTermination(60L, TimeUnit.SECONDS); - } catch (InterruptedException ignored) { - } - } - if (server.mobSpawnExecutor != null && server.mobSpawnExecutor.thread.isAlive()) { LOGGER.info("Waiting for mob spawning thread to shutdown..."); try { @@ -67,5 +58,14 @@ public class ShutdownExecutors { } catch (InterruptedException ignored) { } } + + if (AsyncLocator.LOCATING_EXECUTOR_SERVICE != null) { + LOGGER.info("Waiting for structure locating executor to shutdown..."); + AsyncLocator.LOCATING_EXECUTOR_SERVICE.shutdown(); + try { + AsyncLocator.LOCATING_EXECUTOR_SERVICE.awaitTermination(60L, TimeUnit.SECONDS); + } catch (InterruptedException ignored) { + } + } } } diff --git a/leaf-server/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java b/leaf-server/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java index 1fb04084..aadec6dc 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java @@ -46,10 +46,9 @@ public class AsyncLocator { } static { - int threads = org.dreeam.leaf.config.modules.async.AsyncLocator.asyncLocatorThreads; - LOCATING_EXECUTOR_SERVICE = new ThreadPoolExecutor( + LOCATING_EXECUTOR_SERVICE = !org.dreeam.leaf.config.modules.async.AsyncLocator.enabled ? null : new ThreadPoolExecutor( 1, - threads, + org.dreeam.leaf.config.modules.async.AsyncLocator.asyncLocatorThreads, org.dreeam.leaf.config.modules.async.AsyncLocator.asyncLocatorKeepalive, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),