Browse Source

Warehouse deleted from db

combat-2
MagicBot 8 months ago
parent
commit
12c1cde069
  1. 12
      src/engine/db/handlers/dbWarehouseHandler.java
  2. 7
      src/engine/objects/Building.java

12
src/engine/db/handlers/dbWarehouseHandler.java

@ -84,6 +84,18 @@ public class dbWarehouseHandler extends dbHandlerBase {
return transactionsList; 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) { public boolean UPDATE_WAREHOUSE(Warehouse warehouse) {
JSONObject warehouseJSON = new JSONObject(); JSONObject warehouseJSON = new JSONObject();

7
src/engine/objects/Building.java

@ -425,9 +425,10 @@ public class Building extends AbstractWorldObject {
// Special handling of warehouses // Special handling of warehouses
if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) {
if (city != null) DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
city.setWarehouseBuildingID(0); city.warehouse = null;
}
// Special handling of destroyed Spires // Special handling of destroyed Spires

Loading…
Cancel
Save