Migration to org.json

This commit is contained in:
2024-04-22 09:21:46 -04:00
parent d557e30716
commit ba47b30673
6 changed files with 18 additions and 24 deletions
@@ -9,19 +9,18 @@
package engine.db.handlers;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.mbEnums.GameObjectType;
import engine.mbEnums.TransactionType;
import engine.gameManager.DbManager;
import engine.objects.Building;
import engine.objects.City;
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.json.JSONArray;
import org.json.JSONObject;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -106,7 +105,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
JSONArray locks = new JSONArray();
for (mbEnums.ResourceType resource : warehouse.locked)
locks.add(resource.name());
locks.put(resource.name());
warehouseJSON.put("locked", locks);
@@ -127,15 +126,13 @@ public class dbWarehouseHandler extends dbHandlerBase {
public void LOAD_WAREHOUSES() {
JSONParser jsonParser = new JSONParser();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;");
ResultSet rs = preparedStatement.executeQuery()) {
while (rs.next()) {
int cityUID = rs.getInt("cityUUID");
JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse"));
JSONObject jsonObject = new JSONObject(rs.getString("warehouse"));
City city = City.getCity(cityUID);
city.warehouse = new Warehouse(jsonObject);
city.warehouse.city = city;