9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-19 15:09:27 +00:00
Files
SparklyPaperMC/sparklypaper-server/paper-patches/features/0008-Allow-item-version-downgrades.patch
2025-01-14 00:53:10 -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 bd8005cd3a52532f4cb2e123da473f1490b59dbb..2d23110b61024847c8ed554ac5652982a35dd74b 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -85,6 +85,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();
@@ -246,7 +247,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()) {
@@ -676,7 +677,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;
}