Browse Source

Fixing Junk functionality

combat-2
MagicBot 7 months ago
parent
commit
12b6e41432
  1. 3
      src/engine/gameManager/ForgeManager.java
  2. 17
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

3
src/engine/gameManager/ForgeManager.java

@ -37,6 +37,7 @@ public enum ForgeManager implements Runnable { @@ -37,6 +37,7 @@ public enum ForgeManager implements Runnable {
public static final HashMap<Integer, Item> inMemoryItemLookup = new HashMap<>();
public static final HashMap<NPC, ArrayList<Item>> vendorItemLookup = new HashMap<>();
public static final HashMap<NPC, ArrayList<WorkOrder>> vendorWorkOrderLookup = new HashMap<>();
public static final HashMap<Item, WorkOrder> itemWorkOrderLookup = new HashMap<>();
@Override
@ -317,6 +318,7 @@ public enum ForgeManager implements Runnable { @@ -317,6 +318,7 @@ public enum ForgeManager implements Runnable {
workOrder.cooking.remove(memoryItem);
inMemoryItemLookup.remove(memoryItem.objectUUID);
vendorItemLookup.get(workOrder.vendor).remove(memoryItem);
itemWorkOrderLookup.remove(memoryItem);
}
}
@ -334,6 +336,7 @@ public enum ForgeManager implements Runnable { @@ -334,6 +336,7 @@ public enum ForgeManager implements Runnable {
vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>());
vendorItemLookup.get(workOrder.vendor).add(forged_item);
vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);
itemWorkOrderLookup.put(forged_item, workOrder);
// Update NPC window

17
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -332,13 +332,15 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -332,13 +332,15 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) {
MobLoot targetItem;
Item targetItem;
ManageNPCMsg outMsg;
Dispatch dispatch;
if (origin.sellLock.tryLock()) {
try {
targetItem = MobLoot.getFromCache(itemUUID);
targetItem = ForgeManager.inMemoryItemLookup.get(itemUUID);
PlayerCharacter player = origin.getPlayerCharacter();
@ -350,18 +352,17 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -350,18 +352,17 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
return;
if (!ForgeManager.vendorItemLookup.get(vendor).contains(targetItem))
return;
// Cannot junk items without a forge!
if (vendor.getBuilding() == null)
return;
// Delete the item and cancel any pending rolling timer jobs
// Delete the item
targetItem.recycle(vendor);
// todo fix vendor.removeItemFromForge(targetItem);
ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID);
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem);
workOrder.cooking.remove(targetItem);
ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem);
// Refresh vendor's inventory to client

Loading…
Cancel
Save