make wp c not throw npe on invalid tag name

This commit is contained in:
Wagyourtail 2023-03-13 15:31:18 -07:00
parent 790a4f6769
commit 6698505dd8
No known key found for this signature in database
GPG Key ID: 0D30679891BED858
1 changed files with 5 additions and 1 deletions

View File

@ -149,7 +149,11 @@ public class WaypointsCommand extends Command {
logDirect(component); logDirect(component);
} else if (action == Action.CLEAR) { } else if (action == Action.CLEAR) {
args.requireMax(1); args.requireMax(1);
IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString()); String name = args.getString();
IWaypoint.Tag tag = IWaypoint.Tag.getByName(name);
if (tag == null) {
throw new CommandInvalidStateException("Invalid tag, \"" + name + "\"");
}
IWaypoint[] waypoints = ForWaypoints.getWaypointsByTag(this.baritone, tag); IWaypoint[] waypoints = ForWaypoints.getWaypointsByTag(this.baritone, tag);
for (IWaypoint waypoint : waypoints) { for (IWaypoint waypoint : waypoints) {
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);