diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java new file mode 100644 index 00000000..ae2c7ce6 --- /dev/null +++ b/src/engine/gameManager/ForgeManager.java @@ -0,0 +1,19 @@ +package engine.gameManager; + +import engine.loot.WorkOrder; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.DelayQueue; + +public enum ForgeManager implements Runnable { + + FORGE_MANAGER; + + private BlockingQueue workQueue = new DelayQueue(); + ; + + @Override + public void run() { + + } +} diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index bd961bfb..ce2986e1 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -1,15 +1,36 @@ package engine.loot; -import java.time.LocalDateTime; +import org.jetbrains.annotations.NotNull; -public class WorkOrder { +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +import static java.lang.Math.toIntExact; + +public class WorkOrder implements Delayed { public int npcUUID; public int slotCount; public int itemCount; public String prefix; public String suffix; - public LocalDateTime completionTime; + public long completionTime; public boolean canceled; + public WorkOrder() { + + } + + @Override + public long getDelay(TimeUnit unit) { + + long timeRemaining = completionTime - System.currentTimeMillis(); + return unit.convert(timeRemaining, TimeUnit.MILLISECONDS); + + } + + @Override + public int compareTo(@NotNull Delayed o) { + return toIntExact(this.completionTime - ((WorkOrder) o).completionTime); + } }