SPIGOT-6510: Bukkit#createMap throws NullPointerException

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2021-06-12 08:25:43 +10:00
parent 22217fefcd
commit 0e95cf49fe
2 changed files with 8 additions and 6 deletions

View File

@ -12,7 +12,7 @@
public class ItemWorldMap extends ItemWorldMapBase { public class ItemWorldMap extends ItemWorldMapBase {
public static final int IMAGE_WIDTH = 128; public static final int IMAGE_WIDTH = 128;
@@ -68,7 +73,7 @@ @@ -68,14 +73,18 @@
public static Integer d(ItemStack itemstack) { public static Integer d(ItemStack itemstack) {
NBTTagCompound nbttagcompound = itemstack.getTag(); NBTTagCompound nbttagcompound = itemstack.getTag();
@ -20,8 +20,9 @@
+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag + 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) { - private static int a(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
@@ -76,6 +81,10 @@ + 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(); int l = world.getWorldMapCount();
world.a(a(l), worldmap); world.a(a(l), worldmap);

View File

@ -1364,9 +1364,10 @@ public final class CraftServer implements Server {
public CraftMapView createMap(World world) { public CraftMapView createMap(World world) {
Validate.notNull(world, "World cannot be null"); Validate.notNull(world, "World cannot be null");
net.minecraft.world.item.ItemStack stack = new net.minecraft.world.item.ItemStack(Items.MAP, 1); net.minecraft.world.level.World minecraftWorld = ((CraftWorld) world).getHandle();
WorldMap worldmap = ItemWorldMap.getSavedMap(stack, ((CraftWorld) world).getHandle()); // creates a new map at world spawn with the scale of 3, with out tracking position and unlimited tracking
return worldmap.mapView; int newId = ItemWorldMap.a(minecraftWorld, minecraftWorld.getWorldData().a(), minecraftWorld.getWorldData().c(), 3, false, false, minecraftWorld.getDimensionKey());
return minecraftWorld.a(ItemWorldMap.a(newId)).mapView;
} }
@Override @Override