Simplified and optimised code
This commit is contained in:
parent
7218a46211
commit
f4706fff18
@ -51,30 +51,17 @@ public class FarmCommand extends Command {
|
|||||||
range = args.getAs(Integer.class);
|
range = args.getAs(Integer.class);
|
||||||
}
|
}
|
||||||
//waypoint
|
//waypoint
|
||||||
if (args.hasExactly(1)){
|
if (args.has(1)){
|
||||||
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE);
|
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE);
|
||||||
IWaypoint waypoint = null;
|
IWaypoint waypoint = null;
|
||||||
if (args.hasAny() && args.peekString().equals("@")) {
|
switch (waypoints.length) {
|
||||||
long timestamp = args.getAs(Long.class);
|
case 0:
|
||||||
for (IWaypoint iWaypoint : waypoints) {
|
throw new CommandInvalidStateException("No waypoints found");
|
||||||
if (iWaypoint.getCreationTimestamp() == timestamp) {
|
case 1:
|
||||||
waypoint = iWaypoint;
|
waypoint = waypoints[0];
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
}
|
break;
|
||||||
if (waypoint == null) {
|
|
||||||
throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (waypoints.length) {
|
|
||||||
case 0:
|
|
||||||
throw new CommandInvalidStateException("No waypoints found");
|
|
||||||
case 1:
|
|
||||||
waypoint = waypoints[0];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
throw new CommandInvalidStateException("Multiple waypoints were found");
|
throw new CommandInvalidStateException("Multiple waypoints were found");
|
||||||
|
Loading…
Reference in New Issue
Block a user