SteamWar/SpigotCore
Archiviert
13
0

Forced save instead of chunk unloading
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2024-01-19 15:52:25 +01:00
Ursprung d6f1d51bad
Commit 94a012f711
4 geänderte Dateien mit 25 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -350,4 +351,11 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
public int getViewDistance(Player player) { public int getViewDistance(Player player) {
return player.getClientViewDistance(); return player.getClientViewDistance();
} }
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftWorld", "getHandle");
private static final Reflection.MethodInvoker save = Reflection.getMethod("{nms.server.level}.WorldServer", null, Reflection.getClass("{nms.util}.IProgressUpdate"), boolean.class, boolean.class);
@Override
public void syncSave(World world) {
save.invoke(getHandle.invoke(world), null, true, false);
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -111,4 +112,10 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper
public int getViewDistance(Player player) { public int getViewDistance(Player player) {
return 10; return 10;
} }
private static final Reflection.MethodInvoker save = Reflection.getMethod("{obc}.CraftWorld", "save", boolean.class);
@Override
public void syncSave(World world) {
save.invoke(world, true);
}
} }

Datei anzeigen

@ -25,17 +25,17 @@ import com.viaversion.viaversion.api.Via;
import de.steamwar.sql.internal.Statement; import de.steamwar.sql.internal.Statement;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.eclipse.openj9.criu.CRIUSupport; import org.eclipse.openj9.criu.CRIUSupport;
import org.eclipse.openj9.criu.JVMCRIUException; import org.eclipse.openj9.criu.JVMCRIUException;
import sun.misc.Signal; import sun.misc.Signal;
import java.io.*; import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -84,7 +84,7 @@ public class CheckpointUtils {
private static final Reflection.FieldAccessor<List> channelFutures = Reflection.getField(TinyProtocol.serverConnection, List.class, 0, ChannelFuture.class); 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 final Reflection.MethodInvoker bind = Reflection.getMethod(TinyProtocol.serverConnection, null, InetAddress.class, int.class);
private static void freezeInternal(Path path) throws Exception { private static void freezeInternal(Path path) throws Exception {
Bukkit.getWorlds().forEach(world -> Arrays.stream(world.getLoadedChunks()).forEach(Chunk::unload)); Bukkit.getWorlds().forEach(FlatteningWrapper.impl::syncSave);
Statement.closeAll(); Statement.closeAll();
// Close socket // Close socket
@ -96,6 +96,9 @@ public class CheckpointUtils {
} }
channels.clear(); channels.clear();
System.runFinalization();
System.gc();
// Do the checkpoint // Do the checkpoint
path.toFile().mkdirs(); path.toFile().mkdirs();
CRIUSupport criu = new CRIUSupport(path); CRIUSupport criu = new CRIUSupport(path);

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -48,6 +49,8 @@ public class FlatteningWrapper {
void setSpawnPacketType(Object packet, EntityType type); void setSpawnPacketType(Object packet, EntityType type);
int getViewDistance(Player player); int getViewDistance(Player player);
void syncSave(World world);
} }
public enum EntityPose { public enum EntityPose {