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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -830,9 +830,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @param id the id of the map to get
* @return a map view if it exists, or null otherwise
*/
// @Deprecated(since = "1.6.2") // Paper - Not a magic value
@Nullable
public MapView getMap(int id);
MapView getMap(int id);
/**
* Create a new map with an automatically assigned ID.

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;
}