From f9825900cc399e60a3cabc36cf86e8fcb7007464 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:36:23 -0400 Subject: [PATCH] More completion work --- .../handlers/ItemProductionMsgHandler.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index b64e1d94..734dbd6f 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -107,24 +107,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - Item virtualItem = ForgeManager.inMemoryItemLookup.get(msg.itemUUID); - - if (virtualItem == null) - return true; - - //remove from client forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - // Add to NPC inventory - - vendor.charItemManager.addItemToInventory(virtualItem); - - ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); - ForgeManager.itemWorkOrderLookup.remove(virtualItem); + completeItem(msg.itemUUID, vendor, origin); break; case DEPOSIT: depositItem(msg.itemUUID, vendor, origin); @@ -141,6 +124,29 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return true; } + private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin) { + + + Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + + if (virtualItem == null) + return; + + //remove from client forge window + + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Add to NPC inventory + + vendor.charItemManager.addItemToInventory(virtualItem); + + ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + } + private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { Item targetItem;