diff options
author | Zach Brown <[email protected]> | 2020-08-06 20:24:26 -0400 |
---|---|---|
committer | Aikar <[email protected]> | 2020-08-06 20:24:26 -0400 |
commit | f65f95ce3f1279c7dfe81252be877153ff4cdc99 (patch) | |
tree | 8c5299cc097f6501b3e98af5c4b1f3b62544ff82 | |
parent | 1799ef14089ba2eaaca24c858d78b71e9a7ef552 (diff) | |
download | Paper-f65f95ce3f1279c7dfe81252be877153ff4cdc99.tar.gz Paper-f65f95ce3f1279c7dfe81252be877153ff4cdc99.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.
This restores patch we had for older versions.
-rw-r--r-- | Spigot-Server-Patches/0555-Do-not-let-the-server-load-chunks-from-newer-version.patch | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0555-Do-not-let-the-server-load-chunks-from-newer-version.patch b/Spigot-Server-Patches/0555-Do-not-let-the-server-load-chunks-from-newer-version.patch new file mode 100644 index 0000000000..8150180991 --- /dev/null +++ b/Spigot-Server-Patches/0555-Do-not-let-the-server-load-chunks-from-newer-version.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 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 1685237dfd7d6f352c5bab5f65817462de5e6d12..55a9b9cac2f882c5fe14eb7da2cbbfd532461bfb 100644 +--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java ++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +@@ -50,9 +50,23 @@ public class ChunkRegionLoader { + return holder.protoChunk; + } + ++ // Paper start ++ private static final int CURRENT_DATA_VERSION = SharedConstants.getGameVersion().getWorldVersion(); ++ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); ++ // Paper end ++ + public static InProgressChunkHolder loadChunk(WorldServer worldserver, DefinedStructureManager definedstructuremanager, VillagePlace villageplace, ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound, boolean distinguish) { + ArrayDeque<Runnable> tasksToExecuteOnMain = new ArrayDeque<>(); + // Paper end ++ // Paper start - Do NOT attempt to load chunks saved with newer versions ++ if (nbttagcompound.hasKeyOfType("DataVersion", 99)) { ++ 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 + ChunkGenerator<?> chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); + WorldChunkManager worldchunkmanager = chunkgenerator.getWorldChunkManager(); + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level"); // Paper - diff on change, see ChunkRegionLoader#getChunkCoordinate |