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
This commit is contained in:
Shane Freeder 2020-01-23 21:38:17 +00:00
parent 602f614630
commit 7894e27ddc
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
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());
}
// ========================================================================
--