diff --git a/src/main/java/baritone/chunk/Waypoint.java b/src/main/java/baritone/chunk/Waypoint.java index 091c958c..8b290d56 100644 --- a/src/main/java/baritone/chunk/Waypoint.java +++ b/src/main/java/baritone/chunk/Waypoint.java @@ -17,12 +17,11 @@ package baritone.chunk; +import com.google.common.collect.ImmutableList; import net.minecraft.util.math.BlockPos; +import org.apache.commons.lang3.ArrayUtils; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * A single waypoint @@ -30,6 +29,7 @@ import java.util.Map; * @author leijurv */ public class Waypoint { + public final String name; public final Tag tag; private final long creationTimestamp; @@ -72,19 +72,21 @@ public class Waypoint { } public enum Tag { - HOME, DEATH, BED, USER; + HOME("home", "base"), + DEATH("death"), + BED("bed", "spawn"), + USER(); - } + private static final List TAG_LIST = ImmutableList.builder().add(Tag.values()).build(); - public static final Map TAG_MAP; + private final String[] names; - static { - HashMap map = new HashMap<>(); - map.put("home", Tag.HOME); - map.put("base", Tag.HOME); - map.put("bed", Tag.BED); - map.put("spawn", Tag.BED); - map.put("death", Tag.DEATH); - TAG_MAP = Collections.unmodifiableMap(map); + Tag(String... names) { + this.names = names; + } + + public static Tag fromString(String name) { + return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null); + } } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 3b9cc18e..57906ff0 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -195,7 +195,7 @@ public class ExampleBaritoneControl extends Behavior { // for example, "show deaths" waypointType = waypointType.substring(0, waypointType.length() - 1); } - Waypoint.Tag tag = Waypoint.TAG_MAP.get(waypointType); + Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); if (tag == null) { displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); @@ -218,7 +218,7 @@ public class ExampleBaritoneControl extends Behavior { // for example, "show deaths" waypointType = waypointType.substring(0, waypointType.length() - 1); } - Waypoint.Tag tag = Waypoint.TAG_MAP.get(waypointType); + Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); if (tag == null) { displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel();