aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZach Brown <[email protected]>2019-07-23 20:46:56 -0500
committerZach Brown <[email protected]>2019-07-23 20:46:56 -0500
commit75dd53c6ca1f90d5e6bc2cc35cbfd195b9e199ce (patch)
tree8ea3aa32a17ffb7656fdab3002af3cd1dbcadc99
parentde6476fab3bb982140bd125d78e473a68f4b3885 (diff)
downloadPaper-75dd53c6ca1f90d5e6bc2cc35cbfd195b9e199ce.tar.gz
Paper-75dd53c6ca1f90d5e6bc2cc35cbfd195b9e199ce.zip
Do not let the server load chunks from newer versions
If the server attempts to load a chunk generated by a newer version of the game immediately stop the server to prevent data corruption. You can override this functionality at your own peril.
-rw-r--r--Spigot-Server-Patches/0443-Do-not-let-the-server-load-chunks-from-newer-version.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0443-Do-not-let-the-server-load-chunks-from-newer-version.patch b/Spigot-Server-Patches/0443-Do-not-let-the-server-load-chunks-from-newer-version.patch
new file mode 100644
index 0000000000..07cef370ee
--- /dev/null
+++ b/Spigot-Server-Patches/0443-Do-not-let-the-server-load-chunks-from-newer-version.patch
@@ -0,0 +1,40 @@
+From 93a3a2f86bd4571ff2d8e3a66ba2c2d97f79356a Mon Sep 17 00:00:00 2001
+From: Zach Brown <[email protected]>
+Date: Tue, 23 Jul 2019 20:44:47 -0500
+Subject: [PATCH] Do not let the server load chunks from newer versions
+
+If the server attempts to load a chunk generated by a newer version of
+the game, immediately stop the server to prevent data corruption.
+
+You can override this functionality at your own peril.
+
+diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+index dce52ac0f..9c22e343a 100644
+--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+@@ -288,8 +288,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ }
+ }
+
++ // Paper start
++ private static final int CURRENT_DATA_VERSION = 1631;
++ private static final boolean JUST_CORRUPT_IT = Boolean.valueOf("Paper.ignoreWorldDataVersion");
++ // Paper end
++
+ @Nullable
+ protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
++ // Paper start - Do NOT attempt to load chunks saved with newer versions
++ if (nbttagcompound.hasKeyOfType("DataVersion", 3)) {
++ int dataVersion = nbttagcompound.getInt("DataVersion");
++ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) {
++ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace();
++ System.exit(1);
++ }
++ }
++ // Paper end
+ if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
+ ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
+
+--
+2.22.0
+