From 7fa6593bdc38a54424b97dca108cc3c48e86fe03 Mon Sep 17 00:00:00 2001 From: 0x22 <0x22@futureclient.net> Date: Tue, 4 Jun 2019 01:02:54 -0400 Subject: [PATCH] Added the command delete. Allows you to remove a user defined waypoint. Fixes #334 --- .../baritone/api/utils/ExampleBaritoneControl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 29b42d699..2445f6341 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -68,6 +68,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener "get - Same as list\n" + "show - Same as list\n" + "save - Saves a waypoint (works but don't try to make sense of it)\n" + + "delete - Deletes a waypoint\n" + "goto - Paths towards specified block or waypoint\n" + "spawn - Paths towards world spawn or your most recent bed right-click\n" + "sethome - Sets \"home\"\n" + @@ -583,6 +584,17 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints."); return true; } + if (msg.startsWith("delete")) { + String name = msg.substring(6).trim(); + IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); + if (waypoint == null) { + logDirect("No user defined position under the name '" + name + "' found."); + return true; + } + baritone.getWorldProvider().getCurrentWorld().getWaypoints().removeWaypoint(waypoint); + logDirect("Deleted user defined position under name '" + name + "'."); + return true; + } if (msg.startsWith("goto")) { String waypointType = msg.substring(4).trim(); if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {