[SPIGOT-7535] MapMeta#setMapView(MapView) always throws an exception Created: 06/Dec/23  Updated: 25/Dec/24  Resolved: 08/Dec/23

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Conure Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: bug, spigot

Version: This server is running CraftBukkit version 3956-Spigot-9d72885-5a7080b (MC: 1.20.3) (Implementing API version 1.20.3-R0.1-SNAPSHOT) You are running the latest version
Guidelines Read: Yes

 Description   

I'm developing a plugin that calls setMapView on a MapMeta object. I've had this code working for a very long time, and after updating to 1.20.3 it completely broke. Whenever I try to create a Map item to give to the player, it stops working, and this exception appears in the server logs:

java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "text" is null
     at org.bukkit.craftbukkit.v1_20_R3.map.CraftMapView.getId(CraftMapView.java:36)
     at org.bukkit.craftbukkit.v1_20_R3.inventory.CraftMetaMap.setMapView(CraftMetaMap.java:157)

And subsequent lines just point to where I called this method in my plugin.

Other info:

  • I've verified that both my MapMeta and the MapView that I'm passing into it are not null
  • I checked the Spigot code for CraftMapView (which is listed in the error message), and it seems like CraftMapView.getId() pulls from a field called worldMap.id, which seems to be what's null in this case. I'm not really sure how to go about fixing this.
  • There doesn't seem to be any sort of workaround for this issue, other than issuing a server command along the lines of "/give @s filled_map{map:id}"

Generated at Tue Apr 22 05:09:36 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.