-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
CraftBukkit version git-Spigot-065a373-03b145b (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
-
Yes
The following code:
final ItemStack itemStack = new ItemStack(Material.ARMOR_STAND); final ItemMeta meta = itemStack.getItemMeta(); meta.setDisplayName("Custom name"); itemStack.setItemMeta(meta); System.out.println(itemStack.toString());// or itemStack.serialize()
(in Plugin.onEnable(), but not limited to there) causes following exception:
java.lang.NullPointerException: null value in entry: meta-type=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:34) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at com.google.common.collect.ImmutableMapEntry.<init>(ImmutableMapEntry.java:49) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:172) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:248) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftMetaItem.serialize(CraftMetaItem.java:1222) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftMetaItem.toString(CraftMetaItem.java:1372) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_151] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_151] at org.bukkit.inventory.ItemStack.toString(ItemStack.java:237) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at com.darkyen.minecraft.PLUGINNAME.onEnable(PLUGINNAME.java:319) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:461) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:375) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:449) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:266) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:775) [spigot-1.14.4.jar:git-Spigot-065a373-03b145b] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Calling toString on the ItemStack or the result of its serialization is only needed to force a deep serialization of the CraftMetaItem, the issue is present even when serializing manually and is not limited to the toString method.
This may be a possible regression as I have encountered it in my own tests which had worked before the server update from an older 1.14.4 build.