and some more

This commit is contained in:
Nassim Jahnke
2024-12-21 13:45:04 +01:00
parent 82216a59fe
commit 3b0b3a0aef
44 changed files with 418 additions and 794 deletions

View File

@@ -0,0 +1,29 @@
package io.papermc.paper.util;
import org.apache.logging.log4j.LogManager;
public final class LogManagerShutdownThread extends Thread {
static LogManagerShutdownThread INSTANCE = new LogManagerShutdownThread();
public static void hook() {
if (INSTANCE == null) {
throw new IllegalStateException("Cannot re-hook after being unhooked");
}
Runtime.getRuntime().addShutdownHook(INSTANCE);
}
public static void unhook() {
Runtime.getRuntime().removeShutdownHook(INSTANCE);
INSTANCE = null;
}
private LogManagerShutdownThread() {
super("Log4j2 Shutdown Thread");
}
@Override
public void run() {
LogManager.shutdown();
}
}