forked from MagicBane/Server
MagicBot
1 year ago
2 changed files with 43 additions and 3 deletions
@ -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<WorkOrder> workQueue = new DelayQueue(); |
||||||
|
; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -1,15 +1,36 @@ |
|||||||
package engine.loot; |
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 npcUUID; |
||||||
public int slotCount; |
public int slotCount; |
||||||
public int itemCount; |
public int itemCount; |
||||||
public String prefix; |
public String prefix; |
||||||
public String suffix; |
public String suffix; |
||||||
public LocalDateTime completionTime; |
public long completionTime; |
||||||
public boolean canceled; |
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); |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue