diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 80bceeff..25e13db0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -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 { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); - public static final HashMap itemWorkOrderLookup = new HashMap<>(); + public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @Override diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 59d840df..eb922feb 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -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 { 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);