9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 10:29:13 +00:00

fix shutdown

This commit is contained in:
hayanesuru
2025-07-23 18:14:11 +09:00
parent 6f552d491e
commit 80108127c3
2 changed files with 11 additions and 12 deletions

View File

@@ -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) {
}
}
}
}

View File

@@ -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<>(),