From d539e419feedce1ed8b8ea95e85e908985311acd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:15:06 -0400 Subject: [PATCH] Begin adding workOrder logic --- src/engine/gameManager/ForgeManager.java | 9 +++++++-- src/engine/loot/WorkOrder.java | 5 +---- .../net/client/handlers/ItemProductionMsgHandler.java | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f973e544..05f05c35 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -18,7 +18,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private final BlockingQueue workOrders = new DelayQueue(); + private static final BlockingQueue workOrders = new DelayQueue(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); @Override @@ -60,8 +60,13 @@ public enum ForgeManager implements Runnable { } catch (InterruptedException e) { e.printStackTrace(); } - } + } + public static void submit(WorkOrder workOrder) { + workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.completionTime = System.currentTimeMillis() + 10000; + workOrders.add(workOrder); } + } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9d71d792..b8943b86 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.objects.NPC; import org.jetbrains.annotations.NotNull; @@ -19,7 +18,7 @@ import static java.lang.Math.toIntExact; public class WorkOrder implements Delayed { - public int workOrder; + public int workOrderID; public NPC vendor; public int slotCount; public int itemCount; @@ -33,8 +32,6 @@ public class WorkOrder implements Delayed { public WorkOrder() { - this.workOrder = ForgeManager.wordOrderCounter.incrementAndGet(); - this.completionTime = System.currentTimeMillis() + 10000; } @Override diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 587c8f5c..8e2731ab 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -13,6 +13,7 @@ package engine.net.client.handlers; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.mbEnums.ItemType; @@ -75,6 +76,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) isRandom = true; + // Create new work order + + WorkOrder workOrder = new WorkOrder(); + //Create Multiple Item Function.. Fill all empty slots if (msg.size > 0) {