aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZach Brown <[email protected]>2018-10-23 22:06:33 -0400
committerZach Brown <[email protected]>2018-10-23 22:06:33 -0400
commit4297106c093cd24459ecc67675a47192d67ed2fe (patch)
tree467d49fa953204671e40eeccecc006a3c26242a1
parentb15c43a38971a92fff66282e937923cfad488a71 (diff)
downloadPaper-4297106c093cd24459ecc67675a47192d67ed2fe.tar.gz
Paper-4297106c093cd24459ecc67675a47192d67ed2fe.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/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch b/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch
new file mode 100644
index 0000000000..c11afbeaff
--- /dev/null
+++ b/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch
@@ -0,0 +1,40 @@
+From 652ddff89bc697d79803e1fc33b767bc5af0c1a8 Mon Sep 17 00:00:00 2001
+From: Zach Brown <[email protected]>
+Date: Tue, 23 Oct 2018 22:03:37 -0400
+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 bad287fca..e6906effb 100644
+--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+@@ -90,8 +90,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ return nbttagcompound != null ? true : RegionFileCache.chunkExists(this.d, i, j);
+ }
+
++ // Paper start
++ private static final int CURRENT_DATA_VERSION = 1343; // Paper
++ private static final boolean JUST_CORRUPT_IT = Boolean.valueOf("Paper.ignoreWorldDataVersion");
++ // Paper end
++
+ @Nullable
+ protected Object[] a(World world, 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)) {
+ ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j));
+ return null;
+--
+2.19.1
+