diff --git a/src/main/java/net/rptools/maptool/client/ClientMessageHandler.java b/src/main/java/net/rptools/maptool/client/ClientMessageHandler.java index 3e0d16246d..9a2a47b20e 100644 --- a/src/main/java/net/rptools/maptool/client/ClientMessageHandler.java +++ b/src/main/java/net/rptools/maptool/client/ClientMessageHandler.java @@ -536,9 +536,13 @@ private void handle(SetZoneGridSizeMsg msg) { int color = msg.getColor(); var zone = MapTool.getCampaign().getZone(zoneGUID); - zone.getGrid().setSize(size); - zone.getGrid().setOffset(xOffset, yOffset); - zone.setGridColor(color); + // Sometimes these messages can come in as a zone is being removed, so we can't rely on + // its existence + if (zone != null) { + zone.getGrid().setSize(size); + zone.getGrid().setOffset(xOffset, yOffset); + zone.setGridColor(color); + } MapTool.getFrame().refresh(); }); diff --git a/src/main/java/net/rptools/maptool/server/ServerMessageHandler.java b/src/main/java/net/rptools/maptool/server/ServerMessageHandler.java index c181e141f2..855eaa26fe 100644 --- a/src/main/java/net/rptools/maptool/server/ServerMessageHandler.java +++ b/src/main/java/net/rptools/maptool/server/ServerMessageHandler.java @@ -416,10 +416,12 @@ private void handle(SetZoneGridSizeMsg msg) { EventQueue.invokeLater( () -> { Zone zone = server.getCampaign().getZone(GUID.valueOf(msg.getZoneGuid())); - Grid grid = zone.getGrid(); - grid.setSize(msg.getSize()); - grid.setOffset(msg.getXOffset(), msg.getYOffset()); - zone.setGridColor(msg.getColor()); + if (zone != null) { + Grid grid = zone.getGrid(); + grid.setSize(msg.getSize()); + grid.setOffset(msg.getXOffset(), msg.getYOffset()); + zone.setGridColor(msg.getColor()); + } }); }