stabilize pregeneration

This commit is contained in:
Brian Neumann-Fopiano
2026-08-15 12:57:10 -04:00
parent 4535bf3eed
commit d196ffe853
32 changed files with 2013 additions and 169 deletions
@@ -1671,7 +1671,7 @@ public class NMSBinding implements INMSBinding {
MinecraftServer server
) throws IOException {
if (craftServer.isGlobalTickThread()) {
return createCurrentPaperLevelOverrides(server);
return createCurrentPaperLevelOverrides(craftServer, server);
}
if (J.isFolia() && J.isPrimaryThread()) {
throw new IOException("Current Paper world data cannot be staged from a Folia region tick thread.");
@@ -1680,7 +1680,7 @@ public class NMSBinding implements INMSBinding {
CompletableFuture<PaperLevelOverrides> captured = new CompletableFuture<>();
boolean scheduled = J.runGlobal(() -> {
try {
captured.complete(createCurrentPaperLevelOverrides(server));
captured.complete(createCurrentPaperLevelOverrides(craftServer, server));
} catch (Throwable failure) {
captured.completeExceptionally(failure);
}
@@ -1701,7 +1701,13 @@ public class NMSBinding implements INMSBinding {
}
}
private PaperLevelOverrides createCurrentPaperLevelOverrides(MinecraftServer server) throws IOException {
private PaperLevelOverrides createCurrentPaperLevelOverrides(
CraftServer craftServer,
MinecraftServer server
) throws IOException {
if (!craftServer.isGlobalTickThread()) {
throw new IOException("Current Paper level data must be captured on the global tick thread.");
}
if (!(server.getWorldData().overworldData() instanceof PrimaryLevelData primaryLevelData)) {
throw new IOException("Paper primary level data is unavailable for current world data staging.");
}
@@ -59,12 +59,19 @@ public class NMSBindingCurrentPaperWorldDataContractTest {
assertTrue(capture.contains("craftServer.isGlobalTickThread()"));
assertTrue(capture.contains("J.isFolia() && J.isPrimaryThread()"));
assertTrue(capture.contains("J.runGlobal("));
assertTrue(capture.contains("createCurrentPaperLevelOverrides(craftServer, server)"));
assertTrue(capture.contains("captured.get(CURRENT_WORLD_DATA_SNAPSHOT_TIMEOUT_SECONDS"));
assertTrue(capture.contains("Thread.currentThread().interrupt()"));
assertTrue(create.contains("if (!craftServer.isGlobalTickThread())"));
assertTrue(create.indexOf("if (!craftServer.isGlobalTickThread())")
< create.indexOf("server.getWorldData().overworldData()"));
assertTrue(create.contains("PaperLevelOverrides.createFromLiveLevelData(primaryLevelData)"));
assertFalse(capture.contains("WorldReplacementSeed"));
assertFalse(capture.contains("SavedDataStorage"));
assertFalse(capture.contains("Files."));
assertFalse(create.contains("WorldReplacementSeed"));
assertFalse(create.contains("SavedDataStorage"));
assertFalse(create.contains("Files."));
}
@Test