From 2a2b61bc0f2af6cd27028f1588c63a0f9c348822 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:43:13 -0400 Subject: [PATCH] Method to load workorders on bootstrap --- .../db/handlers/dbWarehouseHandler.java | 19 +++++++++++++++++++ src/engine/loot/WorkOrder.java | 2 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 843113d0..139303e8 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -183,4 +183,23 @@ public class dbWarehouseHandler extends dbHandlerBase { } } + + public void LOAD_WORKORDERS() { + + ArrayList 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); + } + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 82fa1441..bc2a0dfd 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,7 +8,6 @@ package engine.loot; -import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; @@ -50,7 +49,6 @@ public class WorkOrder implements Delayed { public WorkOrder(JSONObject jsonWorkOrder) { - this.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.slots_used = jsonWorkOrder.getInt("slots_used"); this.total_to_produce = jsonWorkOrder.getInt("total_to_produce");