9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-31 12:56:29 +00:00
Files
SparklyPaperMC/patches/server/0021-Allow-item-version-downgrades.patch
MrPowerGamerBR de8a5bf4a7 Fix build
2024-10-29 14:46:29 -03:00

38 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrPowerGamerBR <git@mrpowergamerbr.com>
Date: Fri, 21 Jun 2024 18:07:25 -0300
Subject: [PATCH] Allow item version downgrades
The server WON'T convert the item data from a newer version to an older version, so proceed with caution
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index d06aab9bd5cd901c8367f9680f5d27ddb17b3dc4..52fd5fdbba10f7b1bb5f77e84f1c50d558de037d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -75,6 +75,7 @@ import org.bukkit.potion.PotionType;
public final class CraftMagicNumbers implements UnsafeValues {
public static final CraftMagicNumbers INSTANCE = new CraftMagicNumbers();
public static final boolean DISABLE_OLD_API_SUPPORT = Boolean.getBoolean("paper.disableOldApiSupport"); // Paper
+ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("sparklypaper.ignoreItemDataVersion"); // SparklyPaper - allow item downgrades
private final Commodore commodore = new Commodore();
@@ -242,7 +243,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
@Override
public Material getMaterial(String material, int version) {
Preconditions.checkArgument(material != null, "material == null");
- Preconditions.checkArgument(version <= this.getDataVersion(), "Newer version! Server downgrades are not supported!");
+ Preconditions.checkArgument(JUST_CORRUPT_IT || version <= this.getDataVersion(), "Newer version! Server downgrades are not supported!"); // SparklyPaper - allow item downgrades
// Fastpath up to date materials
if (version == this.getDataVersion()) {
@@ -594,7 +595,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
throw new RuntimeException(ex);
}
int dataVersion = compound.getInt("DataVersion");
- Preconditions.checkArgument(dataVersion <= getDataVersion(), "Newer version! Server downgrades are not supported!");
+ Preconditions.checkArgument(JUST_CORRUPT_IT || dataVersion <= getDataVersion(), "Newer version! Server downgrades are not supported!"); // SparklyPaper - allow item downgrades
return compound;
}