diff --git a/src/main/java/com/almostreliable/merequester/requester/status/ExportState.java b/src/main/java/com/almostreliable/merequester/requester/status/ExportState.java index 425b607..3e23d07 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/ExportState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/ExportState.java @@ -14,7 +14,7 @@ public class ExportState implements StatusState { public StatusState handle(RequesterBlockEntity host, int index) { var storageManager = host.getStorageManager().get(index); if (storageManager.getKey() == null) { - return StatusState.IDLE; + return IDLE; } var inserted = StorageHelper.poweredInsert( @@ -30,9 +30,9 @@ public StatusState handle(RequesterBlockEntity host, int index) { return this; } if (inserted > 0) { - return StatusState.REQUEST; + return REQUEST; } - return StatusState.IDLE; + return IDLE; } @Override diff --git a/src/main/java/com/almostreliable/merequester/requester/status/IdleState.java b/src/main/java/com/almostreliable/merequester/requester/status/IdleState.java index 97ff7ce..5af564d 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/IdleState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/IdleState.java @@ -11,12 +11,12 @@ public class IdleState implements StatusState { @Override public StatusState handle(RequesterBlockEntity host, int index) { if (host.getStorageManager().get(index).getBufferAmount() > 0) { - return StatusState.EXPORT; + return EXPORT; } var request = host.getRequests().get(index); if (request.isRequesting() && request.getAmount() > host.getStorageManager().get(index).getKnownAmount()) { - return StatusState.REQUEST; + return REQUEST; } return this; diff --git a/src/main/java/com/almostreliable/merequester/requester/status/LinkState.java b/src/main/java/com/almostreliable/merequester/requester/status/LinkState.java index d9a57cd..0d0502f 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/LinkState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/LinkState.java @@ -10,11 +10,11 @@ public record LinkState(ICraftingLink link) implements StatusState { @Override public StatusState handle(RequesterBlockEntity host, int slot) { if (link.isDone()) { - return StatusState.EXPORT; + return EXPORT; } if (link.isCanceled()) { - return StatusState.IDLE; + return IDLE; } return this; diff --git a/src/main/java/com/almostreliable/merequester/requester/status/MissingState.java b/src/main/java/com/almostreliable/merequester/requester/status/MissingState.java index 4cdd16c..e9e4b54 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/MissingState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/MissingState.java @@ -22,19 +22,19 @@ public StatusState handle(RequesterBlockEntity host, int slot) { return planSim; } - var idleSim = StatusState.IDLE.handle(host, slot); - if (idleSim == StatusState.IDLE || idleSim == StatusState.EXPORT) { + var idleSim = IDLE.handle(host, slot); + if (idleSim == IDLE || idleSim == EXPORT) { // idle simulation returning idle means a request is no // longer required because we have enough items - // idle state returning export should not be possible + // idle state returning export should not be possible, // but just in case, we will return to idle to handle it - return StatusState.IDLE; + return IDLE; } // idle sim returned that we can request - var requestSim = StatusState.REQUEST.handle(host, slot); - if (requestSim == StatusState.IDLE) { - return StatusState.IDLE; + var requestSim = REQUEST.handle(host, slot); + if (requestSim == IDLE) { + return IDLE; } // request sim returned that we can start planning diff --git a/src/main/java/com/almostreliable/merequester/requester/status/PlanState.java b/src/main/java/com/almostreliable/merequester/requester/status/PlanState.java index b53822e..5b067db 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/PlanState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/PlanState.java @@ -20,23 +20,23 @@ public final class PlanState implements StatusState { @Override public StatusState handle(RequesterBlockEntity host, int index) { if (!future.isDone()) return this; - if (future.isCancelled()) return StatusState.IDLE; + if (future.isCancelled()) return IDLE; try { var plan = future.get(); if (!plan.missingItems().isEmpty()) { - return StatusState.MISSING; + return new MissingState(); } var submitResult = host.getMainNodeGrid().getCraftingService().submitJob(plan, host, null, false, host.getActionSource()); if (!submitResult.successful() || submitResult.link() == null) { - return StatusState.IDLE; + return IDLE; } host.getStorageManager().get(index).setTotalAmount(plan.finalOutput().amount()); return new LinkState(Objects.requireNonNull(submitResult.link())); } catch (InterruptedException | ExecutionException e) { - return StatusState.IDLE; + return IDLE; } } diff --git a/src/main/java/com/almostreliable/merequester/requester/status/RequestState.java b/src/main/java/com/almostreliable/merequester/requester/status/RequestState.java index b01c8be..b8c3d72 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/RequestState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/RequestState.java @@ -12,7 +12,7 @@ public class RequestState implements StatusState { @Override public StatusState handle(RequesterBlockEntity owner, int index) { var amountToCraft = owner.getStorageManager().computeAmountToCraft(index); - if (amountToCraft <= 0) return StatusState.IDLE; + if (amountToCraft <= 0) return IDLE; var key = owner.getRequests().getKey(index); var future = owner diff --git a/src/main/java/com/almostreliable/merequester/requester/status/StatusState.java b/src/main/java/com/almostreliable/merequester/requester/status/StatusState.java index 7177e9e..2fc5559 100644 --- a/src/main/java/com/almostreliable/merequester/requester/status/StatusState.java +++ b/src/main/java/com/almostreliable/merequester/requester/status/StatusState.java @@ -7,7 +7,6 @@ public interface StatusState { StatusState IDLE = new IdleState(); - StatusState MISSING = new MissingState(); StatusState REQUEST = new RequestState(); StatusState EXPORT = new ExportState();