PaperMC/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch
CraftBukkit/Spigot 0e95cf49fe SPIGOT-6510: Bukkit#createMap throws NullPointerException
By: DerFrZocker <derrieple@gmail.com>
2021-06-12 08:25:43 +10:00

35 lines
1.5 KiB
Diff

--- a/net/minecraft/world/item/ItemWorldMap.java
+++ b/net/minecraft/world/item/ItemWorldMap.java
@@ -34,6 +34,11 @@
import net.minecraft.world.level.material.MaterialMapColor;
import net.minecraft.world.level.saveddata.maps.WorldMap;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.server.MapInitializeEvent;
+// CraftBukkit end
+
public class ItemWorldMap extends ItemWorldMapBase {
public static final int IMAGE_WIDTH = 128;
@@ -68,14 +73,18 @@
public static Integer d(ItemStack itemstack) {
NBTTagCompound nbttagcompound = itemstack.getTag();
- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : null;
+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
}
- private static int a(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
+ public static int a(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) { // PAIL private -> public
WorldMap worldmap = WorldMap.a((double) i, (double) j, (byte) k, flag, flag1, resourcekey);
int l = world.getWorldMapCount();
world.a(a(l), worldmap);
+ // CraftBukkit start
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
return l;
}