From 7894e27ddc3c5061407af79b0b533be44e18c2d2 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 23 Jan 2020 21:38:17 +0000 Subject: [PATCH] Init legacy material data This fixes an issue with plugins using legacy materials, spigot does not populate the bukkit registry properly, leading to NPEs when using outdated plugins. This patch should likely be dropped when spigot fixes their legacy data usage.... Also rebuild patches because 10/10 --- ...-items-vanishing-through-end-portal.patch} | 0 .../Init-legacy-material-data.patch | 38 +++++++++++++++++++ 2 files changed, 38 insertions(+) rename Spigot-Server-Patches/{5000.patch => Fix-items-vanishing-through-end-portal.patch} (100%) create mode 100644 Spigot-Server-Patches/Init-legacy-material-data.patch diff --git a/Spigot-Server-Patches/5000.patch b/Spigot-Server-Patches/Fix-items-vanishing-through-end-portal.patch similarity index 100% rename from Spigot-Server-Patches/5000.patch rename to Spigot-Server-Patches/Fix-items-vanishing-through-end-portal.patch diff --git a/Spigot-Server-Patches/Init-legacy-material-data.patch b/Spigot-Server-Patches/Init-legacy-material-data.patch new file mode 100644 index 0000000000..e74396ffb6 --- /dev/null +++ b/Spigot-Server-Patches/Init-legacy-material-data.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Thu, 23 Jan 2020 21:30:07 +0000 +Subject: [PATCH] Init legacy material data + +This fixes an issue with plugins using legacy materials, spigot does +not populate the bukkit registry properly, leading to NPEs when using +outdated plugins. This patch should likely be dropped when spigot fixes +their legacy data usage.... + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index 6a6e4fe486..8d93ad6b45 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { + } + + for (Material material : Material.values()) { +- if (material.isLegacy()) { +- continue; +- } +- + MinecraftKey key = key(material); + IRegistry.ITEM.getOptional(key).ifPresent((item) -> { + MATERIAL_ITEM.put(material, item); +@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { + } + + public static MinecraftKey key(Material mat) { ++ // Paper start ++ if (mat.isLegacy()) { ++ mat = CraftLegacy.fromLegacy(mat); ++ } ++ // Paper end + return CraftNamespacedKey.toMinecraft(mat.getKey()); + } + // ======================================================================== +-- \ No newline at end of file