diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 63699403..bbf6da2e 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -22,6 +22,7 @@ import engine.objects.Warehouse; import engine.server.MBServerStatics; import org.joda.time.DateTime; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.pmw.tinylog.Logger; @@ -134,7 +135,6 @@ public class dbWarehouseHandler extends dbHandlerBase { while (rs.next()) { int cityUID = rs.getInt("cityUUID"); - JSONObject jsonObject = new JSONObject(rs.getString("warehouse")); City city = City.getCity(cityUID); if (city == null) { @@ -142,7 +142,13 @@ public class dbWarehouseHandler extends dbHandlerBase { continue; } - city.warehouse = new Warehouse(jsonObject); + try { + city.warehouse = new Warehouse(new JSONObject(rs.getString("warehouse"))); + } catch (JSONException e) { + Logger.error("Warehouse for city " + cityUID + " failed to load: " + e.getMessage()); + continue; + } + city.warehouse.city = city; // Locate warehouse building