Browse Source

Locks saved to disk

combat-2
MagicBot 8 months ago
parent
commit
264ce39552
  1. 13
      src/engine/db/handlers/dbWarehouseHandler.java

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

@ -19,6 +19,7 @@ import engine.objects.Transaction;
import engine.objects.Warehouse; import engine.objects.Warehouse;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -85,7 +86,17 @@ public class dbWarehouseHandler extends dbHandlerBase {
public boolean UPDATE_WAREHOUSE(Warehouse warehouse) { 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(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse` (`cityUUID`, `warehouse`) VALUES (?, ?) " + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse` (`cityUUID`, `warehouse`) VALUES (?, ?) " +

Loading…
Cancel
Save