Wrap CheckpointUtils for OpenJDK support, remove Border debug messages

This commit is contained in:
Lixfel
2024-11-24 22:12:43 +01:00
parent 7f640ebd34
commit daa17c3e8b
2 changed files with 100 additions and 83 deletions
@@ -64,7 +64,6 @@ public class Border {
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
lastLocation.put(player.getUniqueId(), player.getLocation());
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
}
public boolean contains(Player player) {
@@ -72,7 +71,6 @@ public class Border {
}
public void removePlayer(Player player) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
lastLocation.remove(player.getUniqueId());
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
if(blocks == null || !player.isOnline())
@@ -45,10 +45,27 @@ public class CheckpointUtils {
private CheckpointUtils() {}
public static void signalHandler() {
Signal.handle(new Signal("USR1"), signal -> Bukkit.getScheduler().runTask(Core.getInstance(), CheckpointUtils::freeze));
try {
J9Wrapper.signalHandler();
} catch (NoClassDefFoundError e) {
//ignore
}
}
public static void freeze() {
try {
J9Wrapper.freeze();
} catch (NoClassDefFoundError e) {
//ignore
}
}
private static class J9Wrapper {
private static void signalHandler() {
Signal.handle(new Signal("USR1"), signal -> Bukkit.getScheduler().runTask(Core.getInstance(), CheckpointUtils::freeze));
}
private static void freeze() {
String checkpointFile = System.getProperty("checkpoint");
if(!CRIUSupport.isCheckpointAllowed() || checkpointFile == null) {
Bukkit.shutdown();
@@ -90,6 +107,7 @@ public class CheckpointUtils {
}
}
private static final Reflection.FieldAccessor<List> channelFutures = Reflection.getField(TinyProtocol.serverConnection, List.class, 0, ChannelFuture.class);
private static final Reflection.MethodInvoker bind = Reflection.getMethod(TinyProtocol.serverConnection, null, InetAddress.class, int.class);
private static void freezeInternal(Path path) throws Exception {
@@ -145,3 +163,4 @@ public class CheckpointUtils {
Core.getInstance().getLogger().log(Level.INFO, "Checkpoint restored");
}
}
}