migrate thread cleanup from server.stopped to runtime hook

This commit is contained in:
iceBear67 committed 2026-02-21 18:33:21 +08:00
1 parent 1bd2148df2
commit c1836635fb
1 file changed
+2 -2
@@ -100,9 +100,9 @@ public class JustBackupMod implements ModInitializer {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
this::handleFileChanges
);
ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (watcherThread.getState() != Thread.State.TERMINATED) watcherThread.interrupt();
});
}));
watcherThread.start();
}