Browse Source

Slot tracking update

combat-2
MagicBot 7 months ago
parent
commit
2de1f78f22
  1. 9
      src/engine/gameManager/ForgeManager.java
  2. 10
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

9
src/engine/gameManager/ForgeManager.java

@ -20,10 +20,7 @@ import org.pmw.tinylog.Logger; @@ -20,10 +20,7 @@ import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
public enum ForgeManager implements Runnable {
@ -32,8 +29,8 @@ public enum ForgeManager implements Runnable { @@ -32,8 +29,8 @@ public enum ForgeManager implements Runnable {
private static final BlockingQueue<WorkOrder> forge = new DelayQueue<>();
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
public static final HashMap<NPC, ArrayList<WorkOrder>> vendorWorkOrderLookup = new HashMap<>();
public static final HashMap<Item, WorkOrder> itemWorkOrderLookup = new HashMap<>();
public static final ConcurrentHashMap<NPC, ArrayList<WorkOrder>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
@Override

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

@ -146,6 +146,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -146,6 +146,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
ForgeManager.itemWorkOrderLookup.remove(virtualItem);
DbManager.removeFromCache(virtualItem);
// If this is the last item then remove the workOrder from the game
if (workOrder.cooking.isEmpty())
ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder);
// Persist item and add to vendor inventory
Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem);
@ -388,6 +393,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -388,6 +393,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
DbManager.removeFromCache(virtualItem);
ForgeManager.itemWorkOrderLookup.remove(virtualItem);
// If this is the last item then remove the workOrder from the game
if (workOrder.cooking.isEmpty())
ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder);
// Refresh vendor's inventory to client
outMsg = new ManageNPCMsg(vendor);

Loading…
Cancel
Save