SpoutDev/Spout — Issue #1087: Spoutcraft NPE with PacketItemName packets
Author: desht
Created: 2011-12-01 08:22:17+00:00
State: open

Found in Spout 561 / Spoutcraft 826:

My server-side code is doing this to set the name for a map with a specified ID:

public static void setSpoutMapName(short mapID, String name) {
MaterialData.getOrCreateMaterial(358, mapID).setName(name);
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
SpoutPlayer sp = (SpoutPlayer)p;
if (sp.isSpoutCraftEnabled()) {
sp.sendPacket(new PacketItemName(358, mapID, name));
}
}
}

I get this from Spoutcraft, and the item name doesn't get updated:

[08:08:57] [INFO] [Spoutcraft] Failed to create a duplicate item in MaterialData.getOrCreateMaterial, for 358, 4
[08:08:57] [INFO] ------------------------
[08:08:57] [INFO] Unexpected Exception: PacketItemName
[08:08:57] [SEVERE] java.lang.NullPointerException
[08:08:57] [SEVERE] at org.getspout.spout.packet.PacketItemName.run(PacketItemName.java:70)
[08:08:57] [SEVERE] at org.getspout.spout.packet.CustomPacket.a(CustomPacket.java:132)
[08:08:57] [SEVERE] at hc.b(NetworkManager.java:220)
[08:08:57] [SEVERE] at abp.b(NetClientHandler.java:155)
[08:08:57] [SEVERE] at ri.s_(GuiConnecting.java:141)
[08:08:57] [SEVERE] at net.minecraft.client.Minecraft.k(Minecraft.java:1306)
[08:08:57] [SEVERE] at net.minecraft.client.Minecraft.x(Minecraft.java:730)
[08:08:57] [SEVERE] at net.minecraft.client.Minecraft.run(Minecraft.java:661)
[08:08:57] [SEVERE] at java.lang.Thread.run(Thread.java:662)

This worked OK in the last stable build (Spout 510 / Spoutcraft 769)