From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR 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 507f908916cbeb592496f963b46e4c2121a7b5e3..d9361a5bb576da7f9ea47236620746f21119ab4d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -76,6 +76,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(); @@ -237,7 +238,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()) { @@ -610,7 +611,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; }