From 12c1cde069f3a9a6218cf7b8e3e12f53356cc7d5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Mar 2024 13:21:55 -0400 Subject: [PATCH] Warehouse deleted from db --- src/engine/db/handlers/dbWarehouseHandler.java | 12 ++++++++++++ src/engine/objects/Building.java | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 99cac7e3..329c6069 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -84,6 +84,18 @@ public class dbWarehouseHandler extends dbHandlerBase { return transactionsList; } + public void DELETE_WAREHOUSE(Warehouse warehouse) { + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM ``dyn_warehouse` WHERE `cityUUID` = ?;")) { + preparedStatement.setInt(1, warehouse.city.getObjectUUID()); + preparedStatement.executeUpdate(); + + } catch (SQLException e) { + Logger.error(e); + } + + } + public boolean UPDATE_WAREHOUSE(Warehouse warehouse) { JSONObject warehouseJSON = new JSONObject(); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 1edfd95f..985483fd 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -425,9 +425,10 @@ public class Building extends AbstractWorldObject { // Special handling of warehouses - if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) - if (city != null) - city.setWarehouseBuildingID(0); + if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) { + DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse); + city.warehouse = null; + } // Special handling of destroyed Spires