Fix NPE in Server#getMap before worlds are loaded (#12492)

This commit is contained in:
David
2025-04-28 21:22:33 +02:00
committed by GitHub
parent d1810f241c
commit 02d20ff7eb
2 changed files with 7 additions and 7 deletions

View File

@ -1944,12 +1944,13 @@ public final class CraftServer implements Server {
}
@Override
@Deprecated
public CraftMapView getMap(int id) {
MapItemSavedData mapData = this.console.getLevel(net.minecraft.world.level.Level.OVERWORLD).getMapData(new MapId(id));
if (mapData == null) {
return null;
}
final net.minecraft.world.level.Level overworld = this.console.overworld();
if (overworld == null) return null;
final MapItemSavedData mapData = overworld.getMapData(new MapId(id));
if (mapData == null) return null;
return mapData.mapView;
}