Merge branch 'master' of github.com:cabaletta/baritone
This commit is contained in:
commit
c404258b00
@ -17,12 +17,11 @@
|
|||||||
|
|
||||||
package baritone.chunk;
|
package baritone.chunk;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single waypoint
|
* A single waypoint
|
||||||
@ -30,6 +29,7 @@ import java.util.Map;
|
|||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class Waypoint {
|
public class Waypoint {
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final Tag tag;
|
public final Tag tag;
|
||||||
private final long creationTimestamp;
|
private final long creationTimestamp;
|
||||||
@ -72,19 +72,21 @@ public class Waypoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum Tag {
|
public enum Tag {
|
||||||
HOME, DEATH, BED, USER;
|
HOME("home", "base"),
|
||||||
|
DEATH("death"),
|
||||||
|
BED("bed", "spawn"),
|
||||||
|
USER();
|
||||||
|
|
||||||
|
private static final List<Tag> TAG_LIST = ImmutableList.<Tag>builder().add(Tag.values()).build();
|
||||||
|
|
||||||
|
private final String[] names;
|
||||||
|
|
||||||
|
Tag(String... names) {
|
||||||
|
this.names = names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Map<String, Tag> TAG_MAP;
|
public static Tag fromString(String name) {
|
||||||
|
return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null);
|
||||||
static {
|
}
|
||||||
HashMap<String, Tag> 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
// for example, "show deaths"
|
// for example, "show deaths"
|
||||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
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) {
|
if (tag == null) {
|
||||||
displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
@ -233,7 +233,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
// for example, "show deaths"
|
// for example, "show deaths"
|
||||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
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) {
|
if (tag == null) {
|
||||||
displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user