Files
purpur-quest-board/src/test/java/games/dmg/spigotquestboard/QuestShutdownProcess.java
T
dmg 4abddb5d4d
Release / release (push) Successful in 5m0s
CI / build (push) Successful in 54s
feat(quests): add board bounties and durable reward transfers
2026-09-19 14:06:16 -04:00

28 lines
1.2 KiB
Java

package games.dmg.spigotquestboard;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.Executors;
import java.util.logging.Logger;
/** Forked-JVM fixture: System.exit does not wait for a non-daemon writer without our hook. */
public final class QuestShutdownProcess {
private QuestShutdownProcess() { }
public static void main(String[] args) {
Thread main = Thread.currentThread();
QuestRuntimeScheduler runtime = new QuestRuntimeScheduler(
Executors.newSingleThreadExecutor(Thread.ofPlatform().daemon(false).factory()),
task -> { throw new AssertionError("No Bukkit callbacks may be needed during final disk drain"); },
() -> Thread.currentThread() == main);
runtime.installShutdownBoundary(Logger.getLogger("shutdown-process"));
runtime.worker().execute(() -> {
try {
Thread.sleep(300);
Files.writeString(Path.of(args[0]), "accepted escrow persisted");
} catch (Exception exception) { throw new AssertionError(exception); }
});
runtime.closeRecovering(() -> true);
System.exit(0);
}
}