Browse Source

Method to load workorders on bootstrap

combat-2
MagicBot 7 months ago
parent
commit
2a2b61bc0f
  1. 19
      src/engine/db/handlers/dbWarehouseHandler.java
  2. 2
      src/engine/loot/WorkOrder.java

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

@ -183,4 +183,23 @@ public class dbWarehouseHandler extends dbHandlerBase {
} }
} }
public void LOAD_WORKORDERS() {
ArrayList<WorkOrder> deleteList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;");
ResultSet rs = preparedStatement.executeQuery()) {
while (rs.next()) {
int workOrderID = rs.getInt("workOrderID");
JSONObject jsonObject = new JSONObject(rs.getString("workorder"));
WorkOrder workOrder = new WorkOrder(jsonObject);
deleteList.add(workOrder);
}
} catch (Exception e) {
Logger.error(e);
}
}
} }

2
src/engine/loot/WorkOrder.java

@ -8,7 +8,6 @@
package engine.loot; package engine.loot;
import engine.gameManager.ForgeManager;
import engine.mbEnums; import engine.mbEnums;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.NPC; import engine.objects.NPC;
@ -50,7 +49,6 @@ public class WorkOrder implements Delayed {
public WorkOrder(JSONObject jsonWorkOrder) { public WorkOrder(JSONObject jsonWorkOrder) {
this.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet();
this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor"));
this.slots_used = jsonWorkOrder.getInt("slots_used"); this.slots_used = jsonWorkOrder.getInt("slots_used");
this.total_to_produce = jsonWorkOrder.getInt("total_to_produce"); this.total_to_produce = jsonWorkOrder.getInt("total_to_produce");

Loading…
Cancel
Save