From 264ce39552ca3afc51b393092882e611f455e3f8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Mar 2024 11:55:00 -0400 Subject: [PATCH] Locks saved to disk --- src/engine/db/handlers/dbWarehouseHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index eda889c3..4a31fd93 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -19,6 +19,7 @@ import engine.objects.Transaction; import engine.objects.Warehouse; import engine.server.MBServerStatics; import org.joda.time.DateTime; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.pmw.tinylog.Logger; @@ -85,7 +86,17 @@ public class dbWarehouseHandler extends dbHandlerBase { public boolean UPDATE_WAREHOUSE(Warehouse warehouse) { - JSONObject warehouseJSON = new JSONObject(warehouse.resources); + JSONObject warehouseJSON = new JSONObject(); + + JSONObject resources = new JSONObject(warehouse.resources); + warehouseJSON.put("resources", resources); + + JSONArray locks = new JSONArray(); + + for (Enum.ResourceType resource : warehouse.locked) + locks.add(resource.name()); + + warehouseJSON.put("locks", locks); try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse` (`cityUUID`, `warehouse`) VALUES (?, ?) " +