Browse Source

Equals and hash overrides for workObject

combat-2
MagicBot 8 months ago
parent
commit
0d97fa614b
  1. 40
      src/engine/loot/WorkOrder.java

40
src/engine/loot/WorkOrder.java

@ -25,6 +25,7 @@ import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Delayed; import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -184,16 +185,6 @@ public class WorkOrder implements Delayed {
return true; return true;
} }
@Override
public long getDelay(TimeUnit unit) {
long timeRemaining = completionTime - System.currentTimeMillis();
return unit.convert(timeRemaining, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(Delayed o) {
return Long.compare(this.completionTime, ((WorkOrder) o).completionTime);
}
public static JSONObject toJson(WorkOrder workOrder) { public static JSONObject toJson(WorkOrder workOrder) {
@ -251,4 +242,33 @@ public class WorkOrder implements Delayed {
return outSTring; return outSTring;
} }
@Override
public long getDelay(TimeUnit unit) {
long timeRemaining = completionTime - System.currentTimeMillis();
return unit.convert(timeRemaining, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(Delayed o) {
return Long.compare(this.completionTime, ((WorkOrder) o).completionTime);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
WorkOrder otherWorkOrder = (WorkOrder) obj;
return workOrderID == otherWorkOrder.workOrderID;
}
@Override
public int hashCode() {
return Objects.hash(workOrderID);
}
} }

Loading…
Cancel
Save