its too many blank lines
This commit is contained in:
@ -21,6 +21,7 @@ package baritone.api.event.events.type;
|
|||||||
* @author LoganDark
|
* @author LoganDark
|
||||||
*/
|
*/
|
||||||
public class Overrideable<T> {
|
public class Overrideable<T> {
|
||||||
|
|
||||||
private T value;
|
private T value;
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ public class CompositeSchematic extends AbstractSchematic {
|
|||||||
|
|
||||||
private void recalcArr() {
|
private void recalcArr() {
|
||||||
schematicArr = schematics.toArray(new CompositeSchematicEntry[0]);
|
schematicArr = schematics.toArray(new CompositeSchematicEntry[0]);
|
||||||
|
|
||||||
for (CompositeSchematicEntry entry : schematicArr) {
|
for (CompositeSchematicEntry entry : schematicArr) {
|
||||||
this.x = Math.max(x, entry.x + entry.schematic.widthX());
|
this.x = Math.max(x, entry.x + entry.schematic.widthX());
|
||||||
this.y = Math.max(y, entry.y + entry.schematic.heightY());
|
this.y = Math.max(y, entry.y + entry.schematic.heightY());
|
||||||
@ -56,7 +55,6 @@ public class CompositeSchematic extends AbstractSchematic {
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,11 +67,9 @@ public class CompositeSchematic extends AbstractSchematic {
|
|||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||||
CompositeSchematicEntry entry = getSchematic(x, y, z, current);
|
CompositeSchematicEntry entry = getSchematic(x, y, z, current);
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new IllegalStateException("couldn't find schematic for this position");
|
throw new IllegalStateException("couldn't find schematic for this position");
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
|
return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,11 @@ public class FillSchematic extends AbstractSchematic {
|
|||||||
} else if (current.getBlock() != Blocks.AIR) {
|
} else if (current.getBlock() != Blocks.AIR) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IBlockState placeable : approxPlaceable) {
|
for (IBlockState placeable : approxPlaceable) {
|
||||||
if (bom.matches(placeable)) {
|
if (bom.matches(placeable)) {
|
||||||
return placeable;
|
return placeable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bom.getAnyBlockState();
|
return bom.getAnyBlockState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ public class ReplaceSchematic extends MaskSchematic {
|
|||||||
if (cache[x][y][z] == null) {
|
if (cache[x][y][z] == null) {
|
||||||
cache[x][y][z] = filter.has(currentState);
|
cache[x][y][z] = filter.has(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cache[x][y][z];
|
return cache[x][y][z];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,12 +68,9 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
String prefix = settings.prefix.value;
|
String prefix = settings.prefix.value;
|
||||||
boolean forceRun = msg.startsWith(FORCE_COMMAND_PREFIX);
|
boolean forceRun = msg.startsWith(FORCE_COMMAND_PREFIX);
|
||||||
|
|
||||||
if ((settings.prefixControl.value && msg.startsWith(prefix)) || forceRun) {
|
if ((settings.prefixControl.value && msg.startsWith(prefix)) || forceRun) {
|
||||||
event.cancel();
|
event.cancel();
|
||||||
|
|
||||||
String commandStr = msg.substring(forceRun ? FORCE_COMMAND_PREFIX.length() : prefix.length());
|
String commandStr = msg.substring(forceRun ? FORCE_COMMAND_PREFIX.length() : prefix.length());
|
||||||
|
|
||||||
if (!runCommand(commandStr) && !commandStr.trim().isEmpty()) {
|
if (!runCommand(commandStr) && !commandStr.trim().isEmpty()) {
|
||||||
new CommandNotFoundException(CommandExecution.expand(commandStr).first()).handle(null, null);
|
new CommandNotFoundException(CommandExecution.expand(commandStr).first()).handle(null, null);
|
||||||
}
|
}
|
||||||
@ -86,7 +83,6 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
if (settings.echoCommands.value) {
|
if (settings.echoCommands.value) {
|
||||||
String msg = command + rest;
|
String msg = command + rest;
|
||||||
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
|
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
|
||||||
|
|
||||||
ITextComponent component = new TextComponentString(String.format("> %s", toDisplay));
|
ITextComponent component = new TextComponentString(String.format("> %s", toDisplay));
|
||||||
component.getStyle()
|
component.getStyle()
|
||||||
.setColor(TextFormatting.WHITE)
|
.setColor(TextFormatting.WHITE)
|
||||||
@ -98,7 +94,6 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
ClickEvent.Action.RUN_COMMAND,
|
ClickEvent.Action.RUN_COMMAND,
|
||||||
FORCE_COMMAND_PREFIX + msg
|
FORCE_COMMAND_PREFIX + msg
|
||||||
));
|
));
|
||||||
|
|
||||||
logDirect(component);
|
logDirect(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,31 +106,24 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
try {
|
try {
|
||||||
((IGuiScreen) mc.currentScreen).openLink(new URI("https://www.dominos.com/en/pages/order/"));
|
((IGuiScreen) mc.currentScreen).openLink(new URI("https://www.dominos.com/en/pages/order/"));
|
||||||
} catch (NullPointerException | URISyntaxException ignored) {}
|
} catch (NullPointerException | URISyntaxException ignored) {}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.isEmpty()) {
|
if (msg.isEmpty()) {
|
||||||
msg = "help";
|
msg = "help";
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<String, List<CommandArgument>> pair = CommandExecution.expand(msg);
|
Pair<String, List<CommandArgument>> pair = CommandExecution.expand(msg);
|
||||||
String command = pair.first();
|
String command = pair.first();
|
||||||
String rest = msg.substring(pair.first().length());
|
String rest = msg.substring(pair.first().length());
|
||||||
ArgConsumer argc = new ArgConsumer(pair.second());
|
ArgConsumer argc = new ArgConsumer(pair.second());
|
||||||
|
|
||||||
if (!argc.has()) {
|
if (!argc.has()) {
|
||||||
Settings.Setting setting = settings.byLowerName.get(command.toLowerCase(Locale.US));
|
Settings.Setting setting = settings.byLowerName.get(command.toLowerCase(Locale.US));
|
||||||
|
|
||||||
if (setting != null) {
|
if (setting != null) {
|
||||||
logRanCommand(command, rest);
|
logRanCommand(command, rest);
|
||||||
|
|
||||||
if (setting.getValueClass() == Boolean.class) {
|
if (setting.getValueClass() == Boolean.class) {
|
||||||
CommandManager.execute(String.format("set toggle %s", setting.getName()));
|
CommandManager.execute(String.format("set toggle %s", setting.getName()));
|
||||||
} else {
|
} else {
|
||||||
CommandManager.execute(String.format("set %s", setting.getName()));
|
CommandManager.execute(String.format("set %s", setting.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (argc.hasExactlyOne()) {
|
} else if (argc.hasExactlyOne()) {
|
||||||
@ -143,7 +131,6 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
if (setting.getName().equals("logger")) {
|
if (setting.getName().equals("logger")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setting.getName().equalsIgnoreCase(pair.first())) {
|
if (setting.getName().equalsIgnoreCase(pair.first())) {
|
||||||
logRanCommand(command, rest);
|
logRanCommand(command, rest);
|
||||||
CommandManager.execute(String.format("set %s %s", setting.getName(), argc.getString()));
|
CommandManager.execute(String.format("set %s %s", setting.getName(), argc.getString()));
|
||||||
@ -151,16 +138,12 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandExecution execution = CommandExecution.from(pair);
|
CommandExecution execution = CommandExecution.from(pair);
|
||||||
|
|
||||||
if (isNull(execution)) {
|
if (isNull(execution)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logRanCommand(command, rest);
|
logRanCommand(command, rest);
|
||||||
CommandManager.execute(execution);
|
CommandManager.execute(execution);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,30 +152,23 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
if (!settings.prefixControl.value) {
|
if (!settings.prefixControl.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefix = event.prefix.get();
|
String prefix = event.prefix.get();
|
||||||
String commandPrefix = settings.prefix.value;
|
String commandPrefix = settings.prefix.value;
|
||||||
|
|
||||||
if (!prefix.startsWith(commandPrefix)) {
|
if (!prefix.startsWith(commandPrefix)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = prefix.substring(commandPrefix.length());
|
String msg = prefix.substring(commandPrefix.length());
|
||||||
|
|
||||||
List<CommandArgument> args = CommandArgument.from(msg, true);
|
List<CommandArgument> args = CommandArgument.from(msg, true);
|
||||||
Stream<String> stream = tabComplete(msg);
|
Stream<String> stream = tabComplete(msg);
|
||||||
|
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
stream = stream.map(x -> commandPrefix + x);
|
stream = stream.map(x -> commandPrefix + x);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.completions.set(stream.toArray(String[]::new));
|
event.completions.set(stream.toArray(String[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<String> tabComplete(String msg) {
|
public Stream<String> tabComplete(String msg) {
|
||||||
List<CommandArgument> args = CommandArgument.from(msg, true);
|
List<CommandArgument> args = CommandArgument.from(msg, true);
|
||||||
ArgConsumer argc = new ArgConsumer(args);
|
ArgConsumer argc = new ArgConsumer(args);
|
||||||
|
|
||||||
if (argc.hasAtMost(2)) {
|
if (argc.hasAtMost(2)) {
|
||||||
if (argc.hasExactly(1)) {
|
if (argc.hasExactly(1)) {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
@ -201,26 +177,21 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
.filterPrefix(argc.getString())
|
.filterPrefix(argc.getString())
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
|
Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
|
||||||
|
|
||||||
if (nonNull(setting)) {
|
if (nonNull(setting)) {
|
||||||
if (setting.getValueClass() == Boolean.class) {
|
if (setting.getValueClass() == Boolean.class) {
|
||||||
TabCompleteHelper helper = new TabCompleteHelper();
|
TabCompleteHelper helper = new TabCompleteHelper();
|
||||||
|
|
||||||
if ((Boolean) setting.value) {
|
if ((Boolean) setting.value) {
|
||||||
helper.append(Stream.of("true", "false"));
|
helper.append(Stream.of("true", "false"));
|
||||||
} else {
|
} else {
|
||||||
helper.append(Stream.of("false", "true"));
|
helper.append(Stream.of("false", "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper.filterPrefix(argc.getString()).stream();
|
return helper.filterPrefix(argc.getString()).stream();
|
||||||
} else {
|
} else {
|
||||||
return Stream.of(SettingsUtil.settingValueToString(setting));
|
return Stream.of(SettingsUtil.settingValueToString(setting));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandManager.tabComplete(msg);
|
return CommandManager.tabComplete(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ public abstract class Command implements Helper {
|
|||||||
protected IBaritone baritone;
|
protected IBaritone baritone;
|
||||||
protected IPlayerContext ctx;
|
protected IPlayerContext ctx;
|
||||||
protected Minecraft MC = mc;
|
protected Minecraft MC = mc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The names of this command. This is what you put after the command prefix.
|
* The names of this command. This is what you put after the command prefix.
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.api.utils.command.argparser;
|
package baritone.api.utils.command.argparser;
|
||||||
|
|
||||||
public abstract class ArgParser<T> implements IArgParser<T> {
|
public abstract class ArgParser<T> implements IArgParser<T> {
|
||||||
|
|
||||||
private final Class<T> klass;
|
private final Class<T> klass;
|
||||||
|
|
||||||
protected ArgParser(Class<T> klass) {
|
protected ArgParser(Class<T> klass) {
|
||||||
@ -30,6 +31,7 @@ public abstract class ArgParser<T> implements IArgParser<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Stated<T, S> extends ArgParser<T> implements IArgParser.Stated<T, S> {
|
public static abstract class Stated<T, S> extends ArgParser<T> implements IArgParser.Stated<T, S> {
|
||||||
|
|
||||||
private final Class<S> stateKlass;
|
private final Class<S> stateKlass;
|
||||||
|
|
||||||
protected Stated(Class<T> klass, Class<S> stateKlass) {
|
protected Stated(Class<T> klass, Class<S> stateKlass) {
|
||||||
|
@ -25,6 +25,7 @@ import baritone.api.utils.command.registry.Registry;
|
|||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class ArgParserManager {
|
public class ArgParserManager {
|
||||||
|
|
||||||
public static final Registry<ArgParser> REGISTRY = new Registry<>();
|
public static final Registry<ArgParser> REGISTRY = new Registry<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -73,11 +74,9 @@ public class ArgParserManager {
|
|||||||
*/
|
*/
|
||||||
public static <T> T parseStateless(Class<T> klass, CommandArgument arg) {
|
public static <T> T parseStateless(Class<T> klass, CommandArgument arg) {
|
||||||
ArgParser.Stateless<T> parser = getParserStateless(klass);
|
ArgParser.Stateless<T> parser = getParserStateless(klass);
|
||||||
|
|
||||||
if (isNull(parser)) {
|
if (isNull(parser)) {
|
||||||
throw new CommandNoParserForTypeException(klass);
|
throw new CommandNoParserForTypeException(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return parser.parseArg(arg);
|
return parser.parseArg(arg);
|
||||||
} catch (RuntimeException exc) {
|
} catch (RuntimeException exc) {
|
||||||
@ -98,11 +97,9 @@ public class ArgParserManager {
|
|||||||
*/
|
*/
|
||||||
public static <T, S> T parseStated(Class<T> klass, Class<S> stateKlass, CommandArgument arg, S state) {
|
public static <T, S> T parseStated(Class<T> klass, Class<S> stateKlass, CommandArgument arg, S state) {
|
||||||
ArgParser.Stated<T, S> parser = getParserStated(klass, stateKlass);
|
ArgParser.Stated<T, S> parser = getParserStated(klass, stateKlass);
|
||||||
|
|
||||||
if (isNull(parser)) {
|
if (isNull(parser)) {
|
||||||
throw new CommandNoParserForTypeException(klass);
|
throw new CommandNoParserForTypeException(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return parser.parseArg(arg, state);
|
return parser.parseArg(arg, state);
|
||||||
} catch (RuntimeException exc) {
|
} catch (RuntimeException exc) {
|
||||||
|
@ -25,7 +25,9 @@ import java.util.Locale;
|
|||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
public class DefaultArgParsers {
|
public class DefaultArgParsers {
|
||||||
|
|
||||||
public static class IntArgumentParser extends ArgParser<Integer> implements IArgParser.Stateless<Integer> {
|
public static class IntArgumentParser extends ArgParser<Integer> implements IArgParser.Stateless<Integer> {
|
||||||
|
|
||||||
public static final IntArgumentParser INSTANCE = new IntArgumentParser();
|
public static final IntArgumentParser INSTANCE = new IntArgumentParser();
|
||||||
|
|
||||||
public IntArgumentParser() {
|
public IntArgumentParser() {
|
||||||
@ -39,6 +41,7 @@ public class DefaultArgParsers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class LongArgumentParser extends ArgParser<Long> implements IArgParser.Stateless<Long> {
|
public static class LongArgumentParser extends ArgParser<Long> implements IArgParser.Stateless<Long> {
|
||||||
|
|
||||||
public static final LongArgumentParser INSTANCE = new LongArgumentParser();
|
public static final LongArgumentParser INSTANCE = new LongArgumentParser();
|
||||||
|
|
||||||
public LongArgumentParser() {
|
public LongArgumentParser() {
|
||||||
@ -52,6 +55,7 @@ public class DefaultArgParsers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FloatArgumentParser extends ArgParser<Float> implements IArgParser.Stateless<Float> {
|
public static class FloatArgumentParser extends ArgParser<Float> implements IArgParser.Stateless<Float> {
|
||||||
|
|
||||||
public static final FloatArgumentParser INSTANCE = new FloatArgumentParser();
|
public static final FloatArgumentParser INSTANCE = new FloatArgumentParser();
|
||||||
|
|
||||||
public FloatArgumentParser() {
|
public FloatArgumentParser() {
|
||||||
@ -61,16 +65,15 @@ public class DefaultArgParsers {
|
|||||||
@Override
|
@Override
|
||||||
public Float parseArg(CommandArgument arg) throws RuntimeException {
|
public Float parseArg(CommandArgument arg) throws RuntimeException {
|
||||||
String value = arg.value;
|
String value = arg.value;
|
||||||
|
|
||||||
if (!value.matches("^([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$")) {
|
if (!value.matches("^([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$")) {
|
||||||
throw new RuntimeException("failed float format check");
|
throw new RuntimeException("failed float format check");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Float.parseFloat(value);
|
return Float.parseFloat(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DoubleArgumentParser extends ArgParser<Double> implements IArgParser.Stateless<Double> {
|
public static class DoubleArgumentParser extends ArgParser<Double> implements IArgParser.Stateless<Double> {
|
||||||
|
|
||||||
public static final DoubleArgumentParser INSTANCE = new DoubleArgumentParser();
|
public static final DoubleArgumentParser INSTANCE = new DoubleArgumentParser();
|
||||||
|
|
||||||
public DoubleArgumentParser() {
|
public DoubleArgumentParser() {
|
||||||
@ -80,18 +83,16 @@ public class DefaultArgParsers {
|
|||||||
@Override
|
@Override
|
||||||
public Double parseArg(CommandArgument arg) throws RuntimeException {
|
public Double parseArg(CommandArgument arg) throws RuntimeException {
|
||||||
String value = arg.value;
|
String value = arg.value;
|
||||||
|
|
||||||
if (!value.matches("^([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$")) {
|
if (!value.matches("^([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$")) {
|
||||||
throw new RuntimeException("failed double format check");
|
throw new RuntimeException("failed double format check");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Double.parseDouble(value);
|
return Double.parseDouble(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BooleanArgumentParser extends ArgParser<Boolean> implements IArgParser.Stateless<Boolean> {
|
public static class BooleanArgumentParser extends ArgParser<Boolean> implements IArgParser.Stateless<Boolean> {
|
||||||
public static final BooleanArgumentParser INSTANCE = new BooleanArgumentParser();
|
|
||||||
|
|
||||||
|
public static final BooleanArgumentParser INSTANCE = new BooleanArgumentParser();
|
||||||
public static final List<String> TRUTHY_VALUES = asList("1", "true", "yes", "t", "y", "on", "enable");
|
public static final List<String> TRUTHY_VALUES = asList("1", "true", "yes", "t", "y", "on", "enable");
|
||||||
public static final List<String> FALSY_VALUES = asList("0", "false", "no", "f", "n", "off", "disable");
|
public static final List<String> FALSY_VALUES = asList("0", "false", "no", "f", "n", "off", "disable");
|
||||||
|
|
||||||
@ -102,7 +103,6 @@ public class DefaultArgParsers {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean parseArg(CommandArgument arg) throws RuntimeException {
|
public Boolean parseArg(CommandArgument arg) throws RuntimeException {
|
||||||
String value = arg.value;
|
String value = arg.value;
|
||||||
|
|
||||||
if (TRUTHY_VALUES.contains(value.toLowerCase(Locale.US))) {
|
if (TRUTHY_VALUES.contains(value.toLowerCase(Locale.US))) {
|
||||||
return true;
|
return true;
|
||||||
} else if (FALSY_VALUES.contains(value.toLowerCase(Locale.US))) {
|
} else if (FALSY_VALUES.contains(value.toLowerCase(Locale.US))) {
|
||||||
|
@ -20,6 +20,7 @@ package baritone.api.utils.command.argparser;
|
|||||||
import baritone.api.utils.command.argument.CommandArgument;
|
import baritone.api.utils.command.argument.CommandArgument;
|
||||||
|
|
||||||
public interface IArgParser<T> {
|
public interface IArgParser<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the class of this parser.
|
* @return the class of this parser.
|
||||||
*/
|
*/
|
||||||
@ -31,6 +32,7 @@ public interface IArgParser<T> {
|
|||||||
* @see ArgParserManager#REGISTRY
|
* @see ArgParserManager#REGISTRY
|
||||||
*/
|
*/
|
||||||
interface Stateless<T> extends IArgParser<T> {
|
interface Stateless<T> extends IArgParser<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arg The argument to parse.
|
* @param arg The argument to parse.
|
||||||
* @return What it was parsed into.
|
* @return What it was parsed into.
|
||||||
@ -47,6 +49,7 @@ public interface IArgParser<T> {
|
|||||||
* @see ArgParserManager#REGISTRY
|
* @see ArgParserManager#REGISTRY
|
||||||
*/
|
*/
|
||||||
interface Stated<T, S> extends IArgParser<T> {
|
interface Stated<T, S> extends IArgParser<T> {
|
||||||
|
|
||||||
Class<S> getStateKlass();
|
Class<S> getStateKlass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +38,7 @@ import java.util.regex.Pattern;
|
|||||||
* You're recommended to use {@link ArgConsumer}s to handle these. Check out {@link ArgConsumer#from(String)}
|
* You're recommended to use {@link ArgConsumer}s to handle these. Check out {@link ArgConsumer#from(String)}
|
||||||
*/
|
*/
|
||||||
public class CommandArgument {
|
public class CommandArgument {
|
||||||
|
|
||||||
public final int index;
|
public final int index;
|
||||||
public final String value;
|
public final String value;
|
||||||
public final String rawRest;
|
public final String rawRest;
|
||||||
@ -149,14 +150,11 @@ public class CommandArgument {
|
|||||||
argMatcher.group(),
|
argMatcher.group(),
|
||||||
string.substring(argMatcher.start())
|
string.substring(argMatcher.start())
|
||||||
));
|
));
|
||||||
|
|
||||||
lastEnd = argMatcher.end();
|
lastEnd = argMatcher.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preserveEmptyLast && lastEnd < string.length()) {
|
if (preserveEmptyLast && lastEnd < string.length()) {
|
||||||
args.add(new CommandArgument(args.size(), "", ""));
|
args.add(new CommandArgument(args.size(), "", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class BlockById implements IDatatypeFor<Block> {
|
public class BlockById implements IDatatypeFor<Block> {
|
||||||
|
|
||||||
public final Block block;
|
public final Block block;
|
||||||
|
|
||||||
public BlockById() {
|
public BlockById() {
|
||||||
@ -34,7 +35,6 @@ public class BlockById implements IDatatypeFor<Block> {
|
|||||||
|
|
||||||
public BlockById(ArgConsumer consumer) {
|
public BlockById(ArgConsumer consumer) {
|
||||||
ResourceLocation id = new ResourceLocation(consumer.getString());
|
ResourceLocation id = new ResourceLocation(consumer.getString());
|
||||||
|
|
||||||
if ((block = Block.REGISTRY.getObject(id)) == Blocks.AIR) {
|
if ((block = Block.REGISTRY.getObject(id)) == Blocks.AIR) {
|
||||||
throw new IllegalArgumentException("no block found by that id");
|
throw new IllegalArgumentException("no block found by that id");
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
||||||
|
|
||||||
public final Class<? extends Entity> entity;
|
public final Class<? extends Entity> entity;
|
||||||
|
|
||||||
public EntityClassById() {
|
public EntityClassById() {
|
||||||
@ -36,7 +37,6 @@ public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
|||||||
|
|
||||||
public EntityClassById(ArgConsumer consumer) {
|
public EntityClassById(ArgConsumer consumer) {
|
||||||
ResourceLocation id = new ResourceLocation(consumer.getString());
|
ResourceLocation id = new ResourceLocation(consumer.getString());
|
||||||
|
|
||||||
if (isNull(entity = EntityList.REGISTRY.getObject(id))) {
|
if (isNull(entity = EntityList.REGISTRY.getObject(id))) {
|
||||||
throw new IllegalArgumentException("no entity found by that id");
|
throw new IllegalArgumentException("no entity found by that id");
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
public class ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||||
|
|
||||||
public final BlockOptionalMeta selector;
|
public final BlockOptionalMeta selector;
|
||||||
|
|
||||||
public ForBlockOptionalMeta() {
|
public ForBlockOptionalMeta() {
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Locale;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ForEnumFacing implements IDatatypeFor<EnumFacing> {
|
public class ForEnumFacing implements IDatatypeFor<EnumFacing> {
|
||||||
|
|
||||||
private final EnumFacing facing;
|
private final EnumFacing facing;
|
||||||
|
|
||||||
public ForEnumFacing() {
|
public ForEnumFacing() {
|
||||||
|
@ -28,6 +28,7 @@ import java.util.Comparator;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ForWaypoints implements IDatatypeFor<IWaypoint[]> {
|
public class ForWaypoints implements IDatatypeFor<IWaypoint[]> {
|
||||||
|
|
||||||
private final IWaypoint[] waypoints;
|
private final IWaypoint[] waypoints;
|
||||||
|
|
||||||
public ForWaypoints() {
|
public ForWaypoints() {
|
||||||
|
@ -31,6 +31,7 @@ import java.util.stream.Stream;
|
|||||||
* can create an instance for tab completion.
|
* can create an instance for tab completion.
|
||||||
*/
|
*/
|
||||||
public interface IDatatype {
|
public interface IDatatype {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One benefit over datatypes over {@link ArgParser}s is that instead of each command trying to guess what values
|
* One benefit over datatypes over {@link ArgParser}s is that instead of each command trying to guess what values
|
||||||
* the datatype will accept, or simply not tab completing at all, datatypes that support tab completion can provide
|
* the datatype will accept, or simply not tab completing at all, datatypes that support tab completion can provide
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
package baritone.api.utils.command.datatypes;
|
package baritone.api.utils.command.datatypes;
|
||||||
|
|
||||||
public interface IDatatypeFor<T> extends IDatatype {
|
public interface IDatatypeFor<T> extends IDatatype {
|
||||||
|
|
||||||
T get();
|
T get();
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
package baritone.api.utils.command.datatypes;
|
package baritone.api.utils.command.datatypes;
|
||||||
|
|
||||||
public interface IDatatypePost<T, O> extends IDatatype {
|
public interface IDatatypePost<T, O> extends IDatatype {
|
||||||
|
|
||||||
T apply(O original);
|
T apply(O original);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
||||||
|
|
||||||
private final List<EntityPlayer> players =
|
private final List<EntityPlayer> players =
|
||||||
BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().playerEntities;
|
BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().playerEntities;
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
@ -38,13 +39,11 @@ public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
|||||||
|
|
||||||
public PlayerByUsername(ArgConsumer consumer) {
|
public PlayerByUsername(ArgConsumer consumer) {
|
||||||
String username = consumer.getString();
|
String username = consumer.getString();
|
||||||
|
|
||||||
player = players
|
player = players
|
||||||
.stream()
|
.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(username))
|
.filter(s -> s.getName().equalsIgnoreCase(username))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (isNull(player)) {
|
if (isNull(player)) {
|
||||||
throw new IllegalArgumentException("no player found by that username");
|
throw new IllegalArgumentException("no player found by that username");
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlockPos> {
|
public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate x;
|
final RelativeCoordinate x;
|
||||||
final RelativeCoordinate y;
|
final RelativeCoordinate y;
|
||||||
final RelativeCoordinate z;
|
final RelativeCoordinate z;
|
||||||
@ -57,13 +58,10 @@ public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlo
|
|||||||
if (isNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (isNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
consumer.get();
|
consumer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class RelativeCoordinate implements IDatatypePost<Double, Double> {
|
public class RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||||
public static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$");
|
|
||||||
|
|
||||||
|
public static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$");
|
||||||
final boolean isRelative;
|
final boolean isRelative;
|
||||||
final double offset;
|
final double offset;
|
||||||
|
|
||||||
@ -37,11 +37,9 @@ public class RelativeCoordinate implements IDatatypePost<Double, Double> {
|
|||||||
|
|
||||||
public RelativeCoordinate(ArgConsumer consumer) {
|
public RelativeCoordinate(ArgConsumer consumer) {
|
||||||
Matcher matcher = PATTERN.matcher(consumer.getString());
|
Matcher matcher = PATTERN.matcher(consumer.getString());
|
||||||
|
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
throw new IllegalArgumentException("pattern doesn't match");
|
throw new IllegalArgumentException("pattern doesn't match");
|
||||||
}
|
}
|
||||||
|
|
||||||
isRelative = !matcher.group(1).isEmpty();
|
isRelative = !matcher.group(1).isEmpty();
|
||||||
offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2));
|
offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2));
|
||||||
}
|
}
|
||||||
@ -51,7 +49,6 @@ public class RelativeCoordinate implements IDatatypePost<Double, Double> {
|
|||||||
if (isRelative) {
|
if (isRelative) {
|
||||||
return origin + offset;
|
return origin + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +61,6 @@ public class RelativeCoordinate implements IDatatypePost<Double, Double> {
|
|||||||
if (!consumer.has(2) && consumer.getString().matches("^(~|$)")) {
|
if (!consumer.has(2) && consumer.getString().matches("^(~|$)")) {
|
||||||
return Stream.of("~");
|
return Stream.of("~");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import java.util.stream.Stream;
|
|||||||
import static baritone.api.utils.Helper.HELPER;
|
import static baritone.api.utils.Helper.HELPER;
|
||||||
|
|
||||||
public class RelativeFile implements IDatatypePost<File, File> {
|
public class RelativeFile implements IDatatypePost<File, File> {
|
||||||
|
|
||||||
private final Path path;
|
private final Path path;
|
||||||
|
|
||||||
public RelativeFile() {
|
public RelativeFile() {
|
||||||
@ -75,7 +76,6 @@ public class RelativeFile implements IDatatypePost<File, File> {
|
|||||||
Path basePath = currentPath.isAbsolute() ? currentPath.getRoot() : base.toPath();
|
Path basePath = currentPath.isAbsolute() ? currentPath.getRoot() : base.toPath();
|
||||||
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
||||||
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
||||||
|
|
||||||
return Arrays.stream(Objects.requireNonNull(SHUT_THE_FUCK_UP_IOEXCEPTION_NOBODY_LIKES_YOU(
|
return Arrays.stream(Objects.requireNonNull(SHUT_THE_FUCK_UP_IOEXCEPTION_NOBODY_LIKES_YOU(
|
||||||
useParent
|
useParent
|
||||||
? currentFile.getParentFile()
|
? currentFile.getParentFile()
|
||||||
@ -94,11 +94,9 @@ public class RelativeFile implements IDatatypePost<File, File> {
|
|||||||
|
|
||||||
public static File gameDir() {
|
public static File gameDir() {
|
||||||
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
|
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
|
||||||
|
|
||||||
if (gameDir.getName().equals(".")) {
|
if (gameDir.getName().equals(".")) {
|
||||||
return gameDir.getParentFile();
|
return gameDir.getParentFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return gameDir;
|
return gameDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Objects.nonNull;
|
import static java.util.Objects.nonNull;
|
||||||
|
|
||||||
public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate[] coords;
|
final RelativeCoordinate[] coords;
|
||||||
|
|
||||||
public RelativeGoal() {
|
public RelativeGoal() {
|
||||||
@ -39,13 +40,11 @@ public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
|||||||
|
|
||||||
public RelativeGoal(ArgConsumer consumer) {
|
public RelativeGoal(ArgConsumer consumer) {
|
||||||
List<RelativeCoordinate> coordsList = new ArrayList<>();
|
List<RelativeCoordinate> coordsList = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (nonNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (nonNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||||
coordsList.add(consumer.getDatatype(RelativeCoordinate.class));
|
coordsList.add(consumer.getDatatype(RelativeCoordinate.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coords = coordsList.toArray(new RelativeCoordinate[0]);
|
coords = coordsList.toArray(new RelativeCoordinate[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPos> {
|
public class RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate[] coords;
|
final RelativeCoordinate[] coords;
|
||||||
|
|
||||||
public RelativeGoalBlock() {
|
public RelativeGoalBlock() {
|
||||||
@ -52,7 +53,6 @@ public class RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPo
|
|||||||
if (consumer.hasAtMost(3)) {
|
if (consumer.hasAtMost(3)) {
|
||||||
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
|
public class RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate[] coords;
|
final RelativeCoordinate[] coords;
|
||||||
|
|
||||||
public RelativeGoalXZ() {
|
public RelativeGoalXZ() {
|
||||||
@ -50,7 +51,6 @@ public class RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
|
|||||||
if (consumer.hasAtMost(2)) {
|
if (consumer.hasAtMost(2)) {
|
||||||
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> {
|
public class RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate coord;
|
final RelativeCoordinate coord;
|
||||||
|
|
||||||
public RelativeGoalYLevel() {
|
public RelativeGoalYLevel() {
|
||||||
@ -44,7 +45,6 @@ public class RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlock
|
|||||||
if (consumer.hasAtMost(1)) {
|
if (consumer.hasAtMost(1)) {
|
||||||
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
return consumer.tabCompleteDatatype(RelativeCoordinate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import static baritone.api.utils.Helper.HELPER;
|
import static baritone.api.utils.Helper.HELPER;
|
||||||
|
|
||||||
public abstract class CommandErrorMessageException extends CommandException {
|
public abstract class CommandErrorMessageException extends CommandException {
|
||||||
|
|
||||||
protected CommandErrorMessageException(String reason) {
|
protected CommandErrorMessageException(String reason) {
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import baritone.api.utils.command.argument.CommandArgument;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class CommandException extends RuntimeException {
|
public abstract class CommandException extends RuntimeException {
|
||||||
|
|
||||||
protected CommandException(String reason) {
|
protected CommandException(String reason) {
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package baritone.api.utils.command.exception;
|
|||||||
import baritone.api.utils.command.argument.CommandArgument;
|
import baritone.api.utils.command.argument.CommandArgument;
|
||||||
|
|
||||||
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
|
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public final CommandArgument arg;
|
public final CommandArgument arg;
|
||||||
|
|
||||||
protected CommandInvalidArgumentException(CommandArgument arg, String reason) {
|
protected CommandInvalidArgumentException(CommandArgument arg, String reason) {
|
||||||
@ -28,7 +29,6 @@ public abstract class CommandInvalidArgumentException extends CommandErrorMessag
|
|||||||
arg.index == -1 ? "<unknown>" : Integer.toString(arg.index + 1),
|
arg.index == -1 ? "<unknown>" : Integer.toString(arg.index + 1),
|
||||||
reason
|
reason
|
||||||
));
|
));
|
||||||
|
|
||||||
this.arg = arg;
|
this.arg = arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.api.utils.command.exception;
|
package baritone.api.utils.command.exception;
|
||||||
|
|
||||||
public class CommandInvalidStateException extends CommandErrorMessageException {
|
public class CommandInvalidStateException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public CommandInvalidStateException(String reason) {
|
public CommandInvalidStateException(String reason) {
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package baritone.api.utils.command.exception;
|
|||||||
import baritone.api.utils.command.argument.CommandArgument;
|
import baritone.api.utils.command.argument.CommandArgument;
|
||||||
|
|
||||||
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
|
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
|
||||||
|
|
||||||
public CommandInvalidTypeException(CommandArgument arg, String expected) {
|
public CommandInvalidTypeException(CommandArgument arg, String expected) {
|
||||||
super(arg, String.format("Expected %s", expected));
|
super(arg, String.format("Expected %s", expected));
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.api.utils.command.exception;
|
package baritone.api.utils.command.exception;
|
||||||
|
|
||||||
public class CommandNoParserForTypeException extends CommandErrorMessageException {
|
public class CommandNoParserForTypeException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public final Class<?> klass;
|
public final Class<?> klass;
|
||||||
|
|
||||||
public CommandNoParserForTypeException(Class<?> klass) {
|
public CommandNoParserForTypeException(Class<?> klass) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.api.utils.command.exception;
|
package baritone.api.utils.command.exception;
|
||||||
|
|
||||||
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
|
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public CommandNotEnoughArgumentsException(int minArgs) {
|
public CommandNotEnoughArgumentsException(int minArgs) {
|
||||||
super(String.format("Not enough arguments (expected at least %d)", minArgs));
|
super(String.format("Not enough arguments (expected at least %d)", minArgs));
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
import static baritone.api.utils.Helper.HELPER;
|
import static baritone.api.utils.Helper.HELPER;
|
||||||
|
|
||||||
public class CommandNotFoundException extends CommandException {
|
public class CommandNotFoundException extends CommandException {
|
||||||
|
|
||||||
public final String command;
|
public final String command;
|
||||||
|
|
||||||
public CommandNotFoundException(String command) {
|
public CommandNotFoundException(String command) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.api.utils.command.exception;
|
package baritone.api.utils.command.exception;
|
||||||
|
|
||||||
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
|
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public CommandTooManyArgumentsException(int maxArgs) {
|
public CommandTooManyArgumentsException(int maxArgs) {
|
||||||
super(String.format("Too many arguments (expected at most %d)", maxArgs));
|
super(String.format("Too many arguments (expected at most %d)", maxArgs));
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.stream.Collectors;
|
|||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
public class CommandUnhandledException extends CommandErrorMessageException {
|
public class CommandUnhandledException extends CommandErrorMessageException {
|
||||||
|
|
||||||
public static String getStackTrace(Throwable throwable) {
|
public static String getStackTrace(Throwable throwable) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
throwable.printStackTrace(new PrintWriter(sw));
|
throwable.printStackTrace(new PrintWriter(sw));
|
||||||
@ -35,14 +36,12 @@ public class CommandUnhandledException extends CommandErrorMessageException {
|
|||||||
public static String getBaritoneStackTrace(String stackTrace) {
|
public static String getBaritoneStackTrace(String stackTrace) {
|
||||||
List<String> lines = Arrays.stream(stackTrace.split("\n"))
|
List<String> lines = Arrays.stream(stackTrace.split("\n"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
int lastBaritoneLine = 0;
|
int lastBaritoneLine = 0;
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
if (lines.get(i).startsWith("\tat baritone.") && lines.get(i).contains("BaritoneChatControl")) {
|
if (lines.get(i).startsWith("\tat baritone.") && lines.get(i).contains("BaritoneChatControl")) {
|
||||||
lastBaritoneLine = i;
|
lastBaritoneLine = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.join("\n", lines.subList(0, lastBaritoneLine + 1));
|
return String.join("\n", lines.subList(0, lastBaritoneLine + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,21 +51,18 @@ public class CommandUnhandledException extends CommandErrorMessageException {
|
|||||||
|
|
||||||
public static String getFriendlierStackTrace(String stackTrace) {
|
public static String getFriendlierStackTrace(String stackTrace) {
|
||||||
List<String> lines = asList(stackTrace.split("\n"));
|
List<String> lines = asList(stackTrace.split("\n"));
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String line = lines.get(i);
|
String line = lines.get(i);
|
||||||
if (line.startsWith("\tat ")) {
|
if (line.startsWith("\tat ")) {
|
||||||
if (line.startsWith("\tat baritone.")) {
|
if (line.startsWith("\tat baritone.")) {
|
||||||
line = line.replaceFirst("^\tat [a-z.]+?([A-Z])", "\tat $1");
|
line = line.replaceFirst("^\tat [a-z.]+?([A-Z])", "\tat $1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// line = line.replaceFirst("\\(([^)]+)\\)$", "\n\t . $1");
|
// line = line.replaceFirst("\\(([^)]+)\\)$", "\n\t . $1");
|
||||||
line = line.replaceFirst("\\([^:]+:(\\d+)\\)$", ":$1");
|
line = line.replaceFirst("\\([^:]+:(\\d+)\\)$", ":$1");
|
||||||
line = line.replaceFirst("\\(Unknown Source\\)$", "");
|
line = line.replaceFirst("\\(Unknown Source\\)$", "");
|
||||||
lines.set(i, line);
|
lines.set(i, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.join("\n", lines);
|
return String.join("\n", lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,21 +33,19 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class CommandExecution {
|
public class CommandExecution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command itself
|
* The command itself
|
||||||
*/
|
*/
|
||||||
private final Command command;
|
private final Command command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name this command was called with
|
* The name this command was called with
|
||||||
*/
|
*/
|
||||||
public final String label;
|
public final String label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arg consumer
|
* The arg consumer
|
||||||
*/
|
*/
|
||||||
public final ArgConsumer args;
|
public final ArgConsumer args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Baritone settings
|
* The Baritone settings
|
||||||
*/
|
*/
|
||||||
@ -80,7 +78,6 @@ public class CommandExecution {
|
|||||||
e.handle(command, args.args);
|
e.handle(command, args.args);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
|
||||||
new CommandUnhandledException(t).handle(command, args.args);
|
new CommandUnhandledException(t).handle(command, args.args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,11 +88,9 @@ public class CommandExecution {
|
|||||||
|
|
||||||
public static CommandExecution from(String label, ArgConsumer args) {
|
public static CommandExecution from(String label, ArgConsumer args) {
|
||||||
Command command = CommandManager.getCommand(label);
|
Command command = CommandManager.getCommand(label);
|
||||||
|
|
||||||
if (isNull(command)) {
|
if (isNull(command)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandExecution(
|
return new CommandExecution(
|
||||||
command,
|
command,
|
||||||
label,
|
label,
|
||||||
|
@ -55,11 +55,11 @@ import java.util.stream.Stream;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class ArgConsumer implements Cloneable {
|
public class ArgConsumer implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of arguments in this ArgConsumer
|
* The list of arguments in this ArgConsumer
|
||||||
*/
|
*/
|
||||||
public final LinkedList<CommandArgument> args;
|
public final LinkedList<CommandArgument> args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of consumed arguments for this ArgConsumer. The most recently consumed argument is the last one
|
* The list of consumed arguments for this ArgConsumer. The most recently consumed argument is the last one
|
||||||
*/
|
*/
|
||||||
@ -362,7 +362,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
return peekAsOrDefault(type, def, 0);
|
return peekAsOrDefault(type, def, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to use a <b>stateless</b> {@link ArgParser} to parse the argument at the specified index into the specified
|
* Tries to use a <b>stateless</b> {@link ArgParser} to parse the argument at the specified index into the specified
|
||||||
* class
|
* class
|
||||||
@ -743,7 +742,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
public <T extends IDatatype> T getDatatypeOrNull(Class<T> datatype) {
|
public <T extends IDatatype> T getDatatypeOrNull(Class<T> datatype) {
|
||||||
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
||||||
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getDatatype(datatype);
|
return getDatatype(datatype);
|
||||||
} catch (CommandInvalidTypeException e) {
|
} catch (CommandInvalidTypeException e) {
|
||||||
@ -751,7 +749,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
args.addAll(argsSnapshot);
|
args.addAll(argsSnapshot);
|
||||||
consumed.clear();
|
consumed.clear();
|
||||||
consumed.addAll(consumedSnapshot);
|
consumed.addAll(consumedSnapshot);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -790,7 +787,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
public <T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrDefault(Class<D> datatype, O original, T def) {
|
public <T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrDefault(Class<D> datatype, O original, T def) {
|
||||||
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
||||||
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getDatatypePost(datatype, original);
|
return getDatatypePost(datatype, original);
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
@ -798,7 +794,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
args.addAll(argsSnapshot);
|
args.addAll(argsSnapshot);
|
||||||
consumed.clear();
|
consumed.clear();
|
||||||
consumed.addAll(consumedSnapshot);
|
consumed.addAll(consumedSnapshot);
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -855,7 +850,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
public <T, D extends IDatatypeFor<T>> T getDatatypeForOrDefault(Class<D> datatype, T def) {
|
public <T, D extends IDatatypeFor<T>> T getDatatypeForOrDefault(Class<D> datatype, T def) {
|
||||||
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
List<CommandArgument> argsSnapshot = new ArrayList<>(args);
|
||||||
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
List<CommandArgument> consumedSnapshot = new ArrayList<>(consumed);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getDatatypeFor(datatype);
|
return getDatatypeFor(datatype);
|
||||||
} catch (CommandInvalidTypeException e) {
|
} catch (CommandInvalidTypeException e) {
|
||||||
@ -863,7 +857,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
args.addAll(argsSnapshot);
|
args.addAll(argsSnapshot);
|
||||||
consumed.clear();
|
consumed.clear();
|
||||||
consumed.addAll(consumedSnapshot);
|
consumed.addAll(consumedSnapshot);
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -904,7 +897,6 @@ public class ArgConsumer implements Cloneable {
|
|||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (CommandException ignored) {}
|
} catch (CommandException ignored) {}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import static java.util.Arrays.asList;
|
|||||||
import static java.util.Objects.nonNull;
|
import static java.util.Objects.nonNull;
|
||||||
|
|
||||||
public class Paginator<E> implements Helper {
|
public class Paginator<E> implements Helper {
|
||||||
|
|
||||||
public final List<E> entries;
|
public final List<E> entries;
|
||||||
public int pageSize = 8;
|
public int pageSize = 8;
|
||||||
public int page = 1;
|
public int page = 1;
|
||||||
@ -47,7 +48,6 @@ public class Paginator<E> implements Helper {
|
|||||||
|
|
||||||
public Paginator<E> setPageSize(int pageSize) {
|
public Paginator<E> setPageSize(int pageSize) {
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,13 +61,11 @@ public class Paginator<E> implements Helper {
|
|||||||
|
|
||||||
public Paginator<E> skipPages(int pages) {
|
public Paginator<E> skipPages(int pages) {
|
||||||
page += pages;
|
page += pages;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(Function<E, ITextComponent> transform, String commandPrefix) {
|
public void display(Function<E, ITextComponent> transform, String commandPrefix) {
|
||||||
int offset = (page - 1) * pageSize;
|
int offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
for (int i = offset; i < offset + pageSize; i++) {
|
for (int i = offset; i < offset + pageSize; i++) {
|
||||||
if (i < entries.size()) {
|
if (i < entries.size()) {
|
||||||
logDirect(transform.apply(entries.get(i)));
|
logDirect(transform.apply(entries.get(i)));
|
||||||
@ -75,12 +73,9 @@ public class Paginator<E> implements Helper {
|
|||||||
logDirect("--", TextFormatting.DARK_GRAY);
|
logDirect("--", TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPrevPage = nonNull(commandPrefix) && validPage(page - 1);
|
boolean hasPrevPage = nonNull(commandPrefix) && validPage(page - 1);
|
||||||
boolean hasNextPage = nonNull(commandPrefix) && validPage(page + 1);
|
boolean hasNextPage = nonNull(commandPrefix) && validPage(page + 1);
|
||||||
|
|
||||||
ITextComponent prevPageComponent = new TextComponentString("<<");
|
ITextComponent prevPageComponent = new TextComponentString("<<");
|
||||||
|
|
||||||
if (hasPrevPage) {
|
if (hasPrevPage) {
|
||||||
prevPageComponent.getStyle()
|
prevPageComponent.getStyle()
|
||||||
.setClickEvent(new ClickEvent(
|
.setClickEvent(new ClickEvent(
|
||||||
@ -94,9 +89,7 @@ public class Paginator<E> implements Helper {
|
|||||||
} else {
|
} else {
|
||||||
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextComponent nextPageComponent = new TextComponentString(">>");
|
ITextComponent nextPageComponent = new TextComponentString(">>");
|
||||||
|
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
nextPageComponent.getStyle()
|
nextPageComponent.getStyle()
|
||||||
.setClickEvent(new ClickEvent(
|
.setClickEvent(new ClickEvent(
|
||||||
@ -110,7 +103,6 @@ public class Paginator<E> implements Helper {
|
|||||||
} else {
|
} else {
|
||||||
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextComponent pagerComponent = new TextComponentString("");
|
ITextComponent pagerComponent = new TextComponentString("");
|
||||||
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||||
pagerComponent.appendSibling(prevPageComponent);
|
pagerComponent.appendSibling(prevPageComponent);
|
||||||
@ -126,12 +118,9 @@ public class Paginator<E> implements Helper {
|
|||||||
|
|
||||||
public static <T> void paginate(ArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) {
|
public static <T> void paginate(ArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
|
|
||||||
consumer.requireMax(1);
|
consumer.requireMax(1);
|
||||||
|
|
||||||
if (consumer.has()) {
|
if (consumer.has()) {
|
||||||
page = consumer.getAs(Integer.class);
|
page = consumer.getAs(Integer.class);
|
||||||
|
|
||||||
if (!pagi.validPage(page)) {
|
if (!pagi.validPage(page)) {
|
||||||
throw new CommandInvalidTypeException(
|
throw new CommandInvalidTypeException(
|
||||||
consumer.consumed(),
|
consumer.consumed(),
|
||||||
@ -143,13 +132,10 @@ public class Paginator<E> implements Helper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pagi.skipPages(page - pagi.page);
|
pagi.skipPages(page - pagi.page);
|
||||||
|
|
||||||
if (nonNull(pre)) {
|
if (nonNull(pre)) {
|
||||||
pre.run();
|
pre.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
pagi.display(transform, commandPrefix);
|
pagi.display(transform, commandPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ import java.util.stream.Stream;
|
|||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
public class TabCompleteHelper {
|
public class TabCompleteHelper {
|
||||||
|
|
||||||
private Stream<String> stream;
|
private Stream<String> stream;
|
||||||
|
|
||||||
public TabCompleteHelper(String[] base) {
|
public TabCompleteHelper(String[] base) {
|
||||||
@ -80,7 +81,6 @@ public class TabCompleteHelper {
|
|||||||
*/
|
*/
|
||||||
public TabCompleteHelper append(Stream<String> source) {
|
public TabCompleteHelper append(Stream<String> source) {
|
||||||
stream = Stream.concat(stream, source);
|
stream = Stream.concat(stream, source);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,6 @@ public class TabCompleteHelper {
|
|||||||
*/
|
*/
|
||||||
public TabCompleteHelper prepend(Stream<String> source) {
|
public TabCompleteHelper prepend(Stream<String> source) {
|
||||||
stream = Stream.concat(source, stream);
|
stream = Stream.concat(source, stream);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +177,6 @@ public class TabCompleteHelper {
|
|||||||
*/
|
*/
|
||||||
public TabCompleteHelper map(Function<String, String> transform) {
|
public TabCompleteHelper map(Function<String, String> transform) {
|
||||||
stream = stream.map(transform);
|
stream = stream.map(transform);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +189,6 @@ public class TabCompleteHelper {
|
|||||||
*/
|
*/
|
||||||
public TabCompleteHelper filter(Predicate<String> filter) {
|
public TabCompleteHelper filter(Predicate<String> filter) {
|
||||||
stream = stream.filter(filter);
|
stream = stream.filter(filter);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +201,6 @@ public class TabCompleteHelper {
|
|||||||
*/
|
*/
|
||||||
public TabCompleteHelper sort(Comparator<String> comparator) {
|
public TabCompleteHelper sort(Comparator<String> comparator) {
|
||||||
stream = stream.sorted(comparator);
|
stream = stream.sorted(comparator);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import static java.util.Objects.isNull;
|
|||||||
import static java.util.Objects.nonNull;
|
import static java.util.Objects.nonNull;
|
||||||
|
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
|
|
||||||
public static final Registry<Command> REGISTRY = new Registry<>();
|
public static final Registry<Command> REGISTRY = new Registry<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,6 @@ public class CommandManager {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +54,9 @@ public class CommandManager {
|
|||||||
|
|
||||||
public static boolean execute(String string) {
|
public static boolean execute(String string) {
|
||||||
CommandExecution execution = CommandExecution.from(string);
|
CommandExecution execution = CommandExecution.from(string);
|
||||||
|
|
||||||
if (nonNull(execution)) {
|
if (nonNull(execution)) {
|
||||||
execution.execute();
|
execution.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nonNull(execution);
|
return nonNull(execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +73,6 @@ public class CommandManager {
|
|||||||
Pair<String, List<CommandArgument>> pair = CommandExecution.expand(prefix, true);
|
Pair<String, List<CommandArgument>> pair = CommandExecution.expand(prefix, true);
|
||||||
String label = pair.first();
|
String label = pair.first();
|
||||||
List<CommandArgument> args = pair.second();
|
List<CommandArgument> args = pair.second();
|
||||||
|
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.addCommands()
|
.addCommands()
|
||||||
|
@ -33,6 +33,7 @@ import java.util.stream.StreamSupport;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "UnusedReturnValue"})
|
@SuppressWarnings({"unused", "UnusedReturnValue"})
|
||||||
public class Registry<V> {
|
public class Registry<V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An internal linked list of all the entries that are currently registered. This is a linked list so that entries
|
* An internal linked list of all the entries that are currently registered. This is a linked list so that entries
|
||||||
* can be inserted at the beginning, which means that newer entries are encountered first during iteration. This is
|
* can be inserted at the beginning, which means that newer entries are encountered first during iteration. This is
|
||||||
@ -40,14 +41,12 @@ public class Registry<V> {
|
|||||||
* not just use a map.
|
* not just use a map.
|
||||||
*/
|
*/
|
||||||
private final Deque<V> _entries = new LinkedList<>();
|
private final Deque<V> _entries = new LinkedList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A HashSet containing every entry currently registered. Entries are added to this set when something is registered
|
* A HashSet containing every entry currently registered. Entries are added to this set when something is registered
|
||||||
* and removed from the set when they are unregistered. An entry being present in this set indicates that it is
|
* and removed from the set when they are unregistered. An entry being present in this set indicates that it is
|
||||||
* currently registered, can be removed, and should not be reregistered until it is removed.
|
* currently registered, can be removed, and should not be reregistered until it is removed.
|
||||||
*/
|
*/
|
||||||
private final Set<V> registered = new HashSet<>();
|
private final Set<V> registered = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The collection of entries that are currently in this registry. This is a collection (and not a list) because,
|
* The collection of entries that are currently in this registry. This is a collection (and not a list) because,
|
||||||
* internally, entries are stored in a linked list, which is not the same as a normal list.
|
* internally, entries are stored in a linked list, which is not the same as a normal list.
|
||||||
@ -74,10 +73,8 @@ public class Registry<V> {
|
|||||||
if (!registered(entry)) {
|
if (!registered(entry)) {
|
||||||
_entries.addFirst(entry);
|
_entries.addFirst(entry);
|
||||||
registered.add(entry);
|
registered.add(entry);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +88,6 @@ public class Registry<V> {
|
|||||||
if (registered(entry)) {
|
if (registered(entry)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_entries.remove(entry);
|
_entries.remove(entry);
|
||||||
registered.remove(entry);
|
registered.remove(entry);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import baritone.pathing.calc.PathNode;
|
|||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
class LinkedListOpenSet implements IOpenSet {
|
class LinkedListOpenSet implements IOpenSet {
|
||||||
|
|
||||||
private Node first = null;
|
private Node first = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,6 +84,7 @@ class LinkedListOpenSet implements IOpenSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Node { //wrapper with next
|
public static class Node { //wrapper with next
|
||||||
|
|
||||||
private Node nextOpen;
|
private Node nextOpen;
|
||||||
private PathNode val;
|
private PathNode val;
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,9 @@ public class BlacklistCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
||||||
|
|
||||||
if (!proc.isActive()) {
|
if (!proc.isActive()) {
|
||||||
throw new CommandInvalidStateException("GetToBlockProcess is not currently active");
|
throw new CommandInvalidStateException("GetToBlockProcess is not currently active");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc.blacklistClosest()) {
|
if (proc.blacklistClosest()) {
|
||||||
logDirect("Blacklisted closest instances");
|
logDirect("Blacklisted closest instances");
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,14 +45,11 @@ public class BuildCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
File file = args.getDatatypePost(RelativeFile.class, schematicsDir).getAbsoluteFile();
|
File file = args.getDatatypePost(RelativeFile.class, schematicsDir).getAbsoluteFile();
|
||||||
|
|
||||||
if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) {
|
if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) {
|
||||||
file = new File(file.getAbsolutePath() + ".schematic");
|
file = new File(file.getAbsolutePath() + ".schematic");
|
||||||
}
|
}
|
||||||
|
|
||||||
BetterBlockPos origin = ctx.playerFeet();
|
BetterBlockPos origin = ctx.playerFeet();
|
||||||
BetterBlockPos buildOrigin;
|
BetterBlockPos buildOrigin;
|
||||||
|
|
||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
args.requireMax(3);
|
args.requireMax(3);
|
||||||
buildOrigin = args.getDatatype(RelativeBlockPos.class).apply(origin);
|
buildOrigin = args.getDatatype(RelativeBlockPos.class).apply(origin);
|
||||||
@ -60,13 +57,10 @@ public class BuildCommand extends Command {
|
|||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
buildOrigin = origin;
|
buildOrigin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
|
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new CommandInvalidStateException("Couldn't load the schematic");
|
throw new CommandInvalidStateException("Couldn't load the schematic");
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
|
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +70,8 @@ public class BuildCommand extends Command {
|
|||||||
return RelativeFile.tabComplete(args, schematicsDir);
|
return RelativeFile.tabComplete(args, schematicsDir);
|
||||||
} else if (args.has(2)) {
|
} else if (args.has(2)) {
|
||||||
args.get();
|
args.get();
|
||||||
|
|
||||||
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,18 +46,14 @@ public class ChestsCommand extends Command {
|
|||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
Set<Map.Entry<BlockPos, IRememberedInventory>> entries =
|
Set<Map.Entry<BlockPos, IRememberedInventory>> entries =
|
||||||
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
|
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
|
||||||
|
|
||||||
if (entries.isEmpty()) {
|
if (entries.isEmpty()) {
|
||||||
throw new CommandInvalidStateException("No remembered inventories");
|
throw new CommandInvalidStateException("No remembered inventories");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : entries) {
|
for (Map.Entry<BlockPos, IRememberedInventory> entry : entries) {
|
||||||
// betterblockpos has censoring
|
// betterblockpos has censoring
|
||||||
BetterBlockPos pos = new BetterBlockPos(entry.getKey());
|
BetterBlockPos pos = new BetterBlockPos(entry.getKey());
|
||||||
IRememberedInventory inv = entry.getValue();
|
IRememberedInventory inv = entry.getValue();
|
||||||
|
|
||||||
logDirect(pos.toString());
|
logDirect(pos.toString());
|
||||||
|
|
||||||
for (ItemStack item : inv.getContents()) {
|
for (ItemStack item : inv.getContents()) {
|
||||||
ITextComponent component = item.getTextComponent();
|
ITextComponent component = item.getTextComponent();
|
||||||
component.appendText(String.format(" x %d", item.getCount()));
|
component.appendText(String.format(" x %d", item.getCount()));
|
||||||
|
@ -42,22 +42,18 @@ public class ClearareaCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
BetterBlockPos pos1 = ctx.playerFeet();
|
BetterBlockPos pos1 = ctx.playerFeet();
|
||||||
BetterBlockPos pos2;
|
BetterBlockPos pos2;
|
||||||
|
|
||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
args.requireMax(3);
|
args.requireMax(3);
|
||||||
pos2 = args.getDatatype(RelativeBlockPos.class).apply(pos1);
|
pos2 = args.getDatatype(RelativeBlockPos.class).apply(pos1);
|
||||||
} else {
|
} else {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
Goal goal = baritone.getCustomGoalProcess().getGoal();
|
Goal goal = baritone.getCustomGoalProcess().getGoal();
|
||||||
|
|
||||||
if (!(goal instanceof GoalBlock)) {
|
if (!(goal instanceof GoalBlock)) {
|
||||||
throw new CommandInvalidStateException("Goal is not a GoalBlock");
|
throw new CommandInvalidStateException("Goal is not a GoalBlock");
|
||||||
} else {
|
} else {
|
||||||
pos2 = new BetterBlockPos(((GoalBlock) goal).getGoalPos());
|
pos2 = new BetterBlockPos(((GoalBlock) goal).getGoalPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baritone.getBuilderProcess().clearArea(pos1, pos2);
|
baritone.getBuilderProcess().clearArea(pos1, pos2);
|
||||||
logDirect("Success");
|
logDirect("Success");
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,9 @@ public class ComeCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
Entity entity = MC.getRenderViewEntity();
|
Entity entity = MC.getRenderViewEntity();
|
||||||
|
|
||||||
if (isNull(entity)) {
|
if (isNull(entity)) {
|
||||||
throw new CommandInvalidStateException("render view entity is null");
|
throw new CommandInvalidStateException("render view entity is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
||||||
logDirect("Coming");
|
logDirect("Coming");
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ public class DefaultCommands {
|
|||||||
new GcCommand(baritone),
|
new GcCommand(baritone),
|
||||||
new InvertCommand(baritone),
|
new InvertCommand(baritone),
|
||||||
new ClearareaCommand(baritone),
|
new ClearareaCommand(baritone),
|
||||||
|
|
||||||
new TunnelCommand(baritone),
|
new TunnelCommand(baritone),
|
||||||
new RenderCommand(baritone),
|
new RenderCommand(baritone),
|
||||||
new FarmCommand(baritone),
|
new FarmCommand(baritone),
|
||||||
|
@ -42,11 +42,9 @@ public class ExploreCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GoalXZ goal = args.has()
|
GoalXZ goal = args.has()
|
||||||
? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet())
|
? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet())
|
||||||
: new GoalXZ(ctx.playerFeet());
|
: new GoalXZ(ctx.playerFeet());
|
||||||
|
|
||||||
baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
|
baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
|
||||||
logDirect(String.format("Exploring from %s", goal.toString()));
|
logDirect(String.format("Exploring from %s", goal.toString()));
|
||||||
}
|
}
|
||||||
@ -56,7 +54,6 @@ public class ExploreCommand extends Command {
|
|||||||
if (args.hasAtMost(2)) {
|
if (args.hasAtMost(2)) {
|
||||||
return args.tabCompleteDatatype(RelativeGoalXZ.class);
|
return args.tabCompleteDatatype(RelativeGoalXZ.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import java.util.stream.Stream;
|
|||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
public class ExploreFilterCommand extends Command {
|
public class ExploreFilterCommand extends Command {
|
||||||
|
|
||||||
public ExploreFilterCommand(IBaritone baritone) {
|
public ExploreFilterCommand(IBaritone baritone) {
|
||||||
super(baritone, "explorefilter");
|
super(baritone, "explorefilter");
|
||||||
}
|
}
|
||||||
@ -43,7 +44,6 @@ public class ExploreFilterCommand extends Command {
|
|||||||
args.requireMax(2);
|
args.requireMax(2);
|
||||||
File file = args.getDatatypePost(RelativeFile.class, MC.gameDir.getAbsoluteFile().getParentFile());
|
File file = args.getDatatypePost(RelativeFile.class, MC.gameDir.getAbsoluteFile().getParentFile());
|
||||||
boolean invert = false;
|
boolean invert = false;
|
||||||
|
|
||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
if (args.getString().equalsIgnoreCase("invert")) {
|
if (args.getString().equalsIgnoreCase("invert")) {
|
||||||
invert = true;
|
invert = true;
|
||||||
@ -51,7 +51,6 @@ public class ExploreFilterCommand extends Command {
|
|||||||
throw new CommandInvalidTypeException(args.consumed(), "either \"invert\" or nothing");
|
throw new CommandInvalidTypeException(args.consumed(), "either \"invert\" or nothing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
baritone.getExploreProcess().applyJsonFilter(file.toPath().toAbsolutePath(), invert);
|
baritone.getExploreProcess().applyJsonFilter(file.toPath().toAbsolutePath(), invert);
|
||||||
} catch (NoSuchFileException e) {
|
} catch (NoSuchFileException e) {
|
||||||
@ -61,7 +60,6 @@ public class ExploreFilterCommand extends Command {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format("Explore filter applied. Inverted: %s", Boolean.toString(invert)));
|
logDirect(String.format("Explore filter applied. Inverted: %s", Boolean.toString(invert)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +68,6 @@ public class ExploreFilterCommand extends Command {
|
|||||||
if (args.hasExactlyOne()) {
|
if (args.hasExactlyOne()) {
|
||||||
return RelativeFile.tabComplete(args, RelativeFile.gameDir());
|
return RelativeFile.tabComplete(args, RelativeFile.gameDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,13 +40,10 @@ public class FindCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
List<Block> toFind = new ArrayList<>();
|
List<Block> toFind = new ArrayList<>();
|
||||||
|
|
||||||
while (args.has()) {
|
while (args.has()) {
|
||||||
toFind.add(args.getDatatypeFor(BlockById.class));
|
toFind.add(args.getDatatypeFor(BlockById.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
BetterBlockPos origin = ctx.playerFeet();
|
BetterBlockPos origin = ctx.playerFeet();
|
||||||
|
|
||||||
toFind.stream()
|
toFind.stream()
|
||||||
.flatMap(block ->
|
.flatMap(block ->
|
||||||
ctx.worldData().getCachedWorld().getLocationsOf(
|
ctx.worldData().getCachedWorld().getLocationsOf(
|
||||||
|
@ -52,24 +52,19 @@ public class FollowCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMin(1);
|
args.requireMin(1);
|
||||||
|
|
||||||
FollowGroup group;
|
FollowGroup group;
|
||||||
FollowList list;
|
FollowList list;
|
||||||
List<Entity> entities = new ArrayList<>();
|
List<Entity> entities = new ArrayList<>();
|
||||||
List<Class<? extends Entity>> classes = new ArrayList<>();
|
List<Class<? extends Entity>> classes = new ArrayList<>();
|
||||||
|
|
||||||
if (args.hasExactlyOne()) {
|
if (args.hasExactlyOne()) {
|
||||||
baritone.getFollowProcess().follow((group = args.getEnum(FollowGroup.class)).filter);
|
baritone.getFollowProcess().follow((group = args.getEnum(FollowGroup.class)).filter);
|
||||||
} else {
|
} else {
|
||||||
args.requireMin(2);
|
args.requireMin(2);
|
||||||
|
|
||||||
group = null;
|
group = null;
|
||||||
list = args.getEnum(FollowList.class);
|
list = args.getEnum(FollowList.class);
|
||||||
|
|
||||||
while (args.has()) {
|
while (args.has()) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
Object gotten = args.getDatatypeFor(list.datatype);
|
Object gotten = args.getDatatypeFor(list.datatype);
|
||||||
|
|
||||||
if (gotten instanceof Class) {
|
if (gotten instanceof Class) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
classes.add((Class<? extends Entity>) gotten);
|
classes.add((Class<? extends Entity>) gotten);
|
||||||
@ -77,19 +72,16 @@ public class FollowCommand extends Command {
|
|||||||
entities.add((Entity) gotten);
|
entities.add((Entity) gotten);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baritone.getFollowProcess().follow(
|
baritone.getFollowProcess().follow(
|
||||||
classes.isEmpty()
|
classes.isEmpty()
|
||||||
? entities::contains
|
? entities::contains
|
||||||
: e -> classes.stream().anyMatch(c -> c.isInstance(e))
|
: e -> classes.stream().anyMatch(c -> c.isInstance(e))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonNull(group)) {
|
if (nonNull(group)) {
|
||||||
logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US)));
|
logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US)));
|
||||||
} else {
|
} else {
|
||||||
logDirect("Following these types of entities:");
|
logDirect("Following these types of entities:");
|
||||||
|
|
||||||
if (classes.isEmpty()) {
|
if (classes.isEmpty()) {
|
||||||
entities.stream()
|
entities.stream()
|
||||||
.map(Entity::toString)
|
.map(Entity::toString)
|
||||||
@ -114,21 +106,17 @@ public class FollowCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
} else {
|
} else {
|
||||||
Class<? extends IDatatype> followType;
|
Class<? extends IDatatype> followType;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
followType = args.getEnum(FollowList.class).datatype;
|
followType = args.getEnum(FollowList.class).datatype;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
if (isNull(args.peekDatatypeOrNull(followType))) {
|
if (isNull(args.peekDatatypeOrNull(followType))) {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
args.get();
|
args.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return args.tabCompleteDatatype(followType);
|
return args.tabCompleteDatatype(followType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +144,6 @@ public class FollowCommand extends Command {
|
|||||||
PLAYERS(EntityPlayer.class::isInstance); /* ,
|
PLAYERS(EntityPlayer.class::isInstance); /* ,
|
||||||
FRIENDLY(entity -> entity.getAttackTarget() != HELPER.mc.player),
|
FRIENDLY(entity -> entity.getAttackTarget() != HELPER.mc.player),
|
||||||
HOSTILE(FRIENDLY.filter.negate()); */
|
HOSTILE(FRIENDLY.filter.negate()); */
|
||||||
|
|
||||||
final Predicate<Entity> filter;
|
final Predicate<Entity> filter;
|
||||||
|
|
||||||
FollowGroup(Predicate<Entity> filter) {
|
FollowGroup(Predicate<Entity> filter) {
|
||||||
@ -167,7 +154,6 @@ public class FollowCommand extends Command {
|
|||||||
private enum FollowList {
|
private enum FollowList {
|
||||||
ENTITY(EntityClassById.class),
|
ENTITY(EntityClassById.class),
|
||||||
PLAYER(PlayerByUsername.class);
|
PLAYER(PlayerByUsername.class);
|
||||||
|
|
||||||
final Class<? extends IDatatypeFor> datatype;
|
final Class<? extends IDatatypeFor> datatype;
|
||||||
|
|
||||||
FollowList(Class<? extends IDatatypeFor> datatype) {
|
FollowList(Class<? extends IDatatypeFor> datatype) {
|
||||||
|
@ -36,9 +36,7 @@ public class GcCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
logDirect("ok called System.gc()");
|
logDirect("ok called System.gc()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,8 @@ public class GoalCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
||||||
|
|
||||||
if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) {
|
if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) {
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
|
|
||||||
if (nonNull(goalProcess.getGoal())) {
|
if (nonNull(goalProcess.getGoal())) {
|
||||||
goalProcess.setGoal(null);
|
goalProcess.setGoal(null);
|
||||||
logDirect("Cleared goal");
|
logDirect("Cleared goal");
|
||||||
@ -66,7 +64,6 @@ public class GoalCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||||
TabCompleteHelper helper = new TabCompleteHelper();
|
TabCompleteHelper helper = new TabCompleteHelper();
|
||||||
|
|
||||||
if (args.hasExactlyOne()) {
|
if (args.hasExactlyOne()) {
|
||||||
helper.append(Stream.of("reset", "clear", "none", "~"));
|
helper.append(Stream.of("reset", "clear", "none", "~"));
|
||||||
} else {
|
} else {
|
||||||
@ -75,16 +72,13 @@ public class GoalCommand extends Command {
|
|||||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.get();
|
args.get();
|
||||||
|
|
||||||
if (!args.has(2)) {
|
if (!args.has(2)) {
|
||||||
helper.append("~");
|
helper.append("~");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper.filterPrefix(args.getString()).stream();
|
return helper.filterPrefix(args.getString()).stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ public class HelpCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
|
|
||||||
if (!args.has() || args.is(Integer.class)) {
|
if (!args.has() || args.is(Integer.class)) {
|
||||||
Paginator.paginate(
|
Paginator.paginate(
|
||||||
args, new Paginator<>(
|
args, new Paginator<>(
|
||||||
@ -61,20 +60,16 @@ public class HelpCommand extends Command {
|
|||||||
command -> {
|
command -> {
|
||||||
String names = String.join("/", command.names);
|
String names = String.join("/", command.names);
|
||||||
String name = command.names.get(0);
|
String name = command.names.get(0);
|
||||||
|
|
||||||
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
|
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
|
||||||
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
|
|
||||||
ITextComponent namesComponent = new TextComponentString(names);
|
ITextComponent namesComponent = new TextComponentString(names);
|
||||||
namesComponent.getStyle().setColor(TextFormatting.WHITE);
|
namesComponent.getStyle().setColor(TextFormatting.WHITE);
|
||||||
|
|
||||||
ITextComponent hoverComponent = new TextComponentString("");
|
ITextComponent hoverComponent = new TextComponentString("");
|
||||||
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||||
hoverComponent.appendSibling(namesComponent);
|
hoverComponent.appendSibling(namesComponent);
|
||||||
hoverComponent.appendText("\n" + command.getShortDesc());
|
hoverComponent.appendText("\n" + command.getShortDesc());
|
||||||
hoverComponent.appendText("\n\nClick to view full help");
|
hoverComponent.appendText("\n\nClick to view full help");
|
||||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.names.get(0));
|
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.names.get(0));
|
||||||
|
|
||||||
ITextComponent component = new TextComponentString(name);
|
ITextComponent component = new TextComponentString(name);
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(shortDescComponent);
|
component.appendSibling(shortDescComponent);
|
||||||
@ -88,22 +83,18 @@ public class HelpCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
String commandName = args.getString().toLowerCase();
|
String commandName = args.getString().toLowerCase();
|
||||||
Command command = getCommand(commandName);
|
Command command = getCommand(commandName);
|
||||||
|
|
||||||
if (isNull(command)) {
|
if (isNull(command)) {
|
||||||
throw new CommandNotFoundException(commandName);
|
throw new CommandNotFoundException(commandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
||||||
logDirect("");
|
logDirect("");
|
||||||
command.getLongDesc().forEach(this::logDirect);
|
command.getLongDesc().forEach(this::logDirect);
|
||||||
logDirect("");
|
logDirect("");
|
||||||
|
|
||||||
ITextComponent returnComponent = new TextComponentString("Click to return to the help menu");
|
ITextComponent returnComponent = new TextComponentString("Click to return to the help menu");
|
||||||
returnComponent.getStyle().setClickEvent(new ClickEvent(
|
returnComponent.getStyle().setClickEvent(new ClickEvent(
|
||||||
ClickEvent.Action.RUN_COMMAND,
|
ClickEvent.Action.RUN_COMMAND,
|
||||||
FORCE_COMMAND_PREFIX + label
|
FORCE_COMMAND_PREFIX + label
|
||||||
));
|
));
|
||||||
|
|
||||||
logDirect(returnComponent);
|
logDirect(returnComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +104,6 @@ public class HelpCommand extends Command {
|
|||||||
if (args.hasExactlyOne()) {
|
if (args.hasExactlyOne()) {
|
||||||
return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream();
|
return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,20 +41,16 @@ public class InvertCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||||
Goal goal;
|
Goal goal;
|
||||||
|
|
||||||
if (isNull(goal = customGoalProcess.getGoal())) {
|
if (isNull(goal = customGoalProcess.getGoal())) {
|
||||||
throw new CommandInvalidStateException("No goal");
|
throw new CommandInvalidStateException("No goal");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goal instanceof GoalInverted) {
|
if (goal instanceof GoalInverted) {
|
||||||
goal = ((GoalInverted) goal).origin;
|
goal = ((GoalInverted) goal).origin;
|
||||||
} else {
|
} else {
|
||||||
goal = new GoalInverted(goal);
|
goal = new GoalInverted(goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
customGoalProcess.setGoal(goal);
|
customGoalProcess.setGoal(goal);
|
||||||
logDirect(String.format("Goal: %s", goal.toString()));
|
logDirect(String.format("Goal: %s", goal.toString()));
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,9 @@ public class MineCommand extends Command {
|
|||||||
int quantity = args.getAsOrDefault(Integer.class, 0);
|
int quantity = args.getAsOrDefault(Integer.class, 0);
|
||||||
args.requireMin(1);
|
args.requireMin(1);
|
||||||
List<BlockOptionalMeta> boms = new ArrayList<>();
|
List<BlockOptionalMeta> boms = new ArrayList<>();
|
||||||
|
|
||||||
while (args.has()) {
|
while (args.has()) {
|
||||||
boms.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
boms.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldScanner.INSTANCE.repack(ctx);
|
WorldScanner.INSTANCE.repack(ctx);
|
||||||
baritone.getMineProcess().mine(quantity, boms.toArray(new BlockOptionalMeta[0]));
|
baritone.getMineProcess().mine(quantity, boms.toArray(new BlockOptionalMeta[0]));
|
||||||
logDirect(String.format("Mining %s", boms.toString()));
|
logDirect(String.format("Mining %s", boms.toString()));
|
||||||
|
@ -45,14 +45,12 @@ public class PathCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||||
Goal goal;
|
Goal goal;
|
||||||
|
|
||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
args.requireMax(3);
|
args.requireMax(3);
|
||||||
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
||||||
} else if (isNull(goal = customGoalProcess.getGoal())) {
|
} else if (isNull(goal = customGoalProcess.getGoal())) {
|
||||||
throw new CommandInvalidStateException("No goal");
|
throw new CommandInvalidStateException("No goal");
|
||||||
}
|
}
|
||||||
|
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
WorldScanner.INSTANCE.repack(ctx);
|
WorldScanner.INSTANCE.repack(ctx);
|
||||||
customGoalProcess.setGoalAndPath(goal);
|
customGoalProcess.setGoalAndPath(goal);
|
||||||
@ -66,9 +64,7 @@ public class PathCommand extends Command {
|
|||||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.get();
|
args.get();
|
||||||
|
|
||||||
if (!args.has(2)) {
|
if (!args.has(2)) {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.append("~")
|
.append("~")
|
||||||
@ -77,7 +73,6 @@ public class PathCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ public class PauseResumeCommands {
|
|||||||
this.baritone = baritone;
|
this.baritone = baritone;
|
||||||
// array for mutability, non-field so reflection can't touch it
|
// array for mutability, non-field so reflection can't touch it
|
||||||
final boolean[] paused = {false};
|
final boolean[] paused = {false};
|
||||||
|
|
||||||
baritone.getPathingControlManager().registerProcess(
|
baritone.getPathingControlManager().registerProcess(
|
||||||
new IBaritoneProcess() {
|
new IBaritoneProcess() {
|
||||||
@Override
|
@Override
|
||||||
@ -81,16 +80,13 @@ public class PauseResumeCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
pauseCommand = new Command(baritone, "pause") {
|
pauseCommand = new Command(baritone, "pause") {
|
||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
if (paused[0]) {
|
if (paused[0]) {
|
||||||
throw new CommandInvalidStateException("Already paused");
|
throw new CommandInvalidStateException("Already paused");
|
||||||
}
|
}
|
||||||
|
|
||||||
paused[0] = true;
|
paused[0] = true;
|
||||||
logDirect("Paused");
|
logDirect("Paused");
|
||||||
}
|
}
|
||||||
@ -117,16 +113,13 @@ public class PauseResumeCommands {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resumeCommand = new Command(baritone, "resume") {
|
resumeCommand = new Command(baritone, "resume") {
|
||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
if (!paused[0]) {
|
if (!paused[0]) {
|
||||||
throw new CommandInvalidStateException("Not paused");
|
throw new CommandInvalidStateException("Not paused");
|
||||||
}
|
}
|
||||||
|
|
||||||
paused[0] = false;
|
paused[0] = false;
|
||||||
logDirect("Resumed");
|
logDirect("Resumed");
|
||||||
}
|
}
|
||||||
@ -151,12 +144,10 @@ public class PauseResumeCommands {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pausedCommand = new Command(baritone, "paused") {
|
pausedCommand = new Command(baritone, "paused") {
|
||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not "));
|
logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +41,11 @@ public class ProcCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
||||||
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
||||||
|
|
||||||
if (isNull(process)) {
|
if (isNull(process)) {
|
||||||
throw new CommandInvalidStateException("No process in control");
|
throw new CommandInvalidStateException("No process in control");
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format(
|
logDirect(String.format(
|
||||||
"Class: %s\n" +
|
"Class: %s\n" +
|
||||||
"Priority: %f\n" +
|
"Priority: %f\n" +
|
||||||
|
@ -37,7 +37,6 @@ public class RenderCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
BetterBlockPos origin = ctx.playerFeet();
|
BetterBlockPos origin = ctx.playerFeet();
|
||||||
int renderDistance = (MC.gameSettings.renderDistanceChunks + 1) * 16;
|
int renderDistance = (MC.gameSettings.renderDistanceChunks + 1) * 16;
|
||||||
MC.renderGlobal.markBlockRangeForRenderUpdate(
|
MC.renderGlobal.markBlockRangeForRenderUpdate(
|
||||||
@ -48,7 +47,6 @@ public class RenderCommand extends Command {
|
|||||||
255,
|
255,
|
||||||
origin.z + renderDistance
|
origin.z + renderDistance
|
||||||
);
|
);
|
||||||
|
|
||||||
logDirect("Done");
|
logDirect("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +66,10 @@ public class SelCommand extends Command {
|
|||||||
if (!Baritone.settings().renderSelectionCorners.value || pos1 == null) {
|
if (!Baritone.settings().renderSelectionCorners.value || pos1 == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color color = Baritone.settings().colorSelectionPos1.value;
|
Color color = Baritone.settings().colorSelectionPos1.value;
|
||||||
float opacity = Baritone.settings().selectionOpacity.value;
|
float opacity = Baritone.settings().selectionOpacity.value;
|
||||||
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
||||||
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
||||||
|
|
||||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||||
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
||||||
IRenderer.endLines(ignoreDepth);
|
IRenderer.endLines(ignoreDepth);
|
||||||
@ -82,20 +80,16 @@ public class SelCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
Action action = Action.getByName(args.getString());
|
Action action = Action.getByName(args.getString());
|
||||||
|
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == Action.POS1 || action == Action.POS2) {
|
if (action == Action.POS1 || action == Action.POS2) {
|
||||||
if (action == Action.POS2 && pos1 == null) {
|
if (action == Action.POS2 && pos1 == null) {
|
||||||
throw new CommandInvalidStateException("Set pos1 first before using pos2");
|
throw new CommandInvalidStateException("Set pos1 first before using pos2");
|
||||||
}
|
}
|
||||||
|
|
||||||
BetterBlockPos playerPos = ctx.playerFeet();
|
BetterBlockPos playerPos = ctx.playerFeet();
|
||||||
BetterBlockPos pos = args.has() ? args.getDatatypePost(RelativeBlockPos.class, playerPos) : playerPos;
|
BetterBlockPos pos = args.has() ? args.getDatatypePost(RelativeBlockPos.class, playerPos) : playerPos;
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
if (action == Action.POS1) {
|
if (action == Action.POS1) {
|
||||||
pos1 = pos;
|
pos1 = pos;
|
||||||
logDirect("Position 1 has been set");
|
logDirect("Position 1 has been set");
|
||||||
@ -110,13 +104,11 @@ public class SelCommand extends Command {
|
|||||||
logDirect(String.format("Removed %d selections", manager.removeAllSelections().length));
|
logDirect(String.format("Removed %d selections", manager.removeAllSelections().length));
|
||||||
} else if (action == Action.UNDO) {
|
} else if (action == Action.UNDO) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
if (pos1 != null) {
|
if (pos1 != null) {
|
||||||
pos1 = null;
|
pos1 = null;
|
||||||
logDirect("Undid pos1");
|
logDirect("Undid pos1");
|
||||||
} else {
|
} else {
|
||||||
ISelection[] selections = manager.getSelections();
|
ISelection[] selections = manager.getSelections();
|
||||||
|
|
||||||
if (selections.length < 1) {
|
if (selections.length < 1) {
|
||||||
throw new CommandInvalidStateException("Nothing to undo!");
|
throw new CommandInvalidStateException("Nothing to undo!");
|
||||||
} else {
|
} else {
|
||||||
@ -129,33 +121,24 @@ public class SelCommand extends Command {
|
|||||||
? new BlockOptionalMeta(Blocks.AIR)
|
? new BlockOptionalMeta(Blocks.AIR)
|
||||||
: args.getDatatypeFor(ForBlockOptionalMeta.class);
|
: args.getDatatypeFor(ForBlockOptionalMeta.class);
|
||||||
BlockOptionalMetaLookup replaces = null;
|
BlockOptionalMetaLookup replaces = null;
|
||||||
|
|
||||||
if (action == Action.REPLACE) {
|
if (action == Action.REPLACE) {
|
||||||
args.requireMin(1);
|
args.requireMin(1);
|
||||||
|
|
||||||
List<BlockOptionalMeta> replacesList = new ArrayList<>();
|
List<BlockOptionalMeta> replacesList = new ArrayList<>();
|
||||||
|
|
||||||
replacesList.add(type);
|
replacesList.add(type);
|
||||||
|
|
||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
replacesList.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
replacesList.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
type = args.getDatatypeFor(ForBlockOptionalMeta.class);
|
type = args.getDatatypeFor(ForBlockOptionalMeta.class);
|
||||||
replaces = new BlockOptionalMetaLookup(replacesList.toArray(new BlockOptionalMeta[0]));
|
replaces = new BlockOptionalMetaLookup(replacesList.toArray(new BlockOptionalMeta[0]));
|
||||||
} else {
|
} else {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISelection[] selections = manager.getSelections();
|
ISelection[] selections = manager.getSelections();
|
||||||
|
|
||||||
if (selections.length == 0) {
|
if (selections.length == 0) {
|
||||||
throw new CommandInvalidStateException("No selections");
|
throw new CommandInvalidStateException("No selections");
|
||||||
}
|
}
|
||||||
|
|
||||||
BetterBlockPos origin = selections[0].min();
|
BetterBlockPos origin = selections[0].min();
|
||||||
CompositeSchematic composite = new CompositeSchematic(0, 0, 0);
|
CompositeSchematic composite = new CompositeSchematic(0, 0, 0);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
BetterBlockPos min = selection.min();
|
BetterBlockPos min = selection.min();
|
||||||
origin = new BetterBlockPos(
|
origin = new BetterBlockPos(
|
||||||
@ -164,13 +147,10 @@ public class SelCommand extends Command {
|
|||||||
Math.min(origin.z, min.z)
|
Math.min(origin.z, min.z)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
Vec3i size = selection.size();
|
Vec3i size = selection.size();
|
||||||
BetterBlockPos min = selection.min();
|
BetterBlockPos min = selection.min();
|
||||||
|
|
||||||
ISchematic schematic = new FillSchematic(size.getX(), size.getY(), size.getZ(), type);
|
ISchematic schematic = new FillSchematic(size.getX(), size.getY(), size.getZ(), type);
|
||||||
|
|
||||||
if (action == Action.WALLS) {
|
if (action == Action.WALLS) {
|
||||||
schematic = new WallsSchematic(schematic);
|
schematic = new WallsSchematic(schematic);
|
||||||
} else if (action == Action.SHELL) {
|
} else if (action == Action.SHELL) {
|
||||||
@ -178,31 +158,23 @@ public class SelCommand extends Command {
|
|||||||
} else if (action == Action.REPLACE) {
|
} else if (action == Action.REPLACE) {
|
||||||
schematic = new ReplaceSchematic(schematic, replaces);
|
schematic = new ReplaceSchematic(schematic, replaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
composite.put(schematic, min.x - origin.x, min.y - origin.y, min.z - origin.z);
|
composite.put(schematic, min.x - origin.x, min.y - origin.y, min.z - origin.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
baritone.getBuilderProcess().build("Fill", composite, origin);
|
baritone.getBuilderProcess().build("Fill", composite, origin);
|
||||||
logDirect("Filling now");
|
logDirect("Filling now");
|
||||||
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
||||||
args.requireExactly(3);
|
args.requireExactly(3);
|
||||||
TransformTarget transformTarget = TransformTarget.getByName(args.getString());
|
TransformTarget transformTarget = TransformTarget.getByName(args.getString());
|
||||||
|
|
||||||
if (transformTarget == null) {
|
if (transformTarget == null) {
|
||||||
throw new CommandInvalidStateException("Invalid transform type");
|
throw new CommandInvalidStateException("Invalid transform type");
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumFacing direction = args.getDatatypeFor(ForEnumFacing.class);
|
EnumFacing direction = args.getDatatypeFor(ForEnumFacing.class);
|
||||||
int blocks = args.getAs(Integer.class);
|
int blocks = args.getAs(Integer.class);
|
||||||
|
|
||||||
ISelection[] selections = manager.getSelections();
|
ISelection[] selections = manager.getSelections();
|
||||||
|
|
||||||
if (selections.length < 1) {
|
if (selections.length < 1) {
|
||||||
throw new CommandInvalidStateException("No selections found");
|
throw new CommandInvalidStateException("No selections found");
|
||||||
}
|
}
|
||||||
|
|
||||||
selections = transformTarget.transform(selections);
|
selections = transformTarget.transform(selections);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
if (action == Action.EXPAND) {
|
if (action == Action.EXPAND) {
|
||||||
manager.expand(selection, direction, blocks);
|
manager.expand(selection, direction, blocks);
|
||||||
@ -212,7 +184,6 @@ public class SelCommand extends Command {
|
|||||||
manager.shift(selection, direction, blocks);
|
manager.shift(selection, direction, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format("Transformed %d selections", selections.length));
|
logDirect(String.format("Transformed %d selections", selections.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +198,6 @@ public class SelCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
} else {
|
} else {
|
||||||
Action action = Action.getByName(args.getString());
|
Action action = Action.getByName(args.getString());
|
||||||
|
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
if (action == Action.POS1 || action == Action.POS2) {
|
if (action == Action.POS1 || action == Action.POS2) {
|
||||||
if (args.hasAtMost(3)) {
|
if (args.hasAtMost(3)) {
|
||||||
@ -238,7 +208,6 @@ public class SelCommand extends Command {
|
|||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
args.get();
|
args.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return args.tabCompleteDatatype(ForBlockOptionalMeta.class);
|
return args.tabCompleteDatatype(ForBlockOptionalMeta.class);
|
||||||
}
|
}
|
||||||
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
||||||
@ -250,7 +219,6 @@ public class SelCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
} else {
|
} else {
|
||||||
TransformTarget target = TransformTarget.getByName(args.getString());
|
TransformTarget target = TransformTarget.getByName(args.getString());
|
||||||
|
|
||||||
if (target != null && args.hasExactlyOne()) {
|
if (target != null && args.hasExactlyOne()) {
|
||||||
return args.tabCompleteDatatype(ForEnumFacing.class);
|
return args.tabCompleteDatatype(ForEnumFacing.class);
|
||||||
}
|
}
|
||||||
@ -258,7 +226,6 @@ public class SelCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,20 +266,16 @@ public class SelCommand extends Command {
|
|||||||
enum Action {
|
enum Action {
|
||||||
POS1("pos1", "p1", "1"),
|
POS1("pos1", "p1", "1"),
|
||||||
POS2("pos2", "p2", "2"),
|
POS2("pos2", "p2", "2"),
|
||||||
|
|
||||||
CLEAR("clear", "c"),
|
CLEAR("clear", "c"),
|
||||||
UNDO("undo", "u"),
|
UNDO("undo", "u"),
|
||||||
|
|
||||||
SET("set", "fill", "s", "f"),
|
SET("set", "fill", "s", "f"),
|
||||||
WALLS("walls", "w"),
|
WALLS("walls", "w"),
|
||||||
SHELL("shell", "shl"),
|
SHELL("shell", "shl"),
|
||||||
CLEARAREA("cleararea", "ca"),
|
CLEARAREA("cleararea", "ca"),
|
||||||
REPLACE("replace", "r"),
|
REPLACE("replace", "r"),
|
||||||
|
|
||||||
EXPAND("expand", "ex"),
|
EXPAND("expand", "ex"),
|
||||||
CONTRACT("contract", "ct"),
|
CONTRACT("contract", "ct"),
|
||||||
SHIFT("shift", "sh");
|
SHIFT("shift", "sh");
|
||||||
|
|
||||||
private final String[] names;
|
private final String[] names;
|
||||||
|
|
||||||
Action(String... names) {
|
Action(String... names) {
|
||||||
@ -327,17 +290,14 @@ public class SelCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getAllNames() {
|
public static String[] getAllNames() {
|
||||||
Set<String> names = new HashSet<>();
|
Set<String> names = new HashSet<>();
|
||||||
|
|
||||||
for (Action action : Action.values()) {
|
for (Action action : Action.values()) {
|
||||||
names.addAll(asList(action.names));
|
names.addAll(asList(action.names));
|
||||||
}
|
}
|
||||||
|
|
||||||
return names.toArray(new String[0]);
|
return names.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,7 +306,6 @@ public class SelCommand extends Command {
|
|||||||
ALL(sels -> sels, "all", "a"),
|
ALL(sels -> sels, "all", "a"),
|
||||||
NEWEST(sels -> new ISelection[]{sels[sels.length - 1]}, "newest", "n"),
|
NEWEST(sels -> new ISelection[]{sels[sels.length - 1]}, "newest", "n"),
|
||||||
OLDEST(sels -> new ISelection[]{sels[0]}, "oldest", "o");
|
OLDEST(sels -> new ISelection[]{sels[0]}, "oldest", "o");
|
||||||
|
|
||||||
private final Function<ISelection[], ISelection[]> transform;
|
private final Function<ISelection[], ISelection[]> transform;
|
||||||
private final String[] names;
|
private final String[] names;
|
||||||
|
|
||||||
@ -367,17 +326,14 @@ public class SelCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getAllNames() {
|
public static String[] getAllNames() {
|
||||||
Set<String> names = new HashSet<>();
|
Set<String> names = new HashSet<>();
|
||||||
|
|
||||||
for (TransformTarget target : TransformTarget.values()) {
|
for (TransformTarget target : TransformTarget.values()) {
|
||||||
names.addAll(asList(target.names));
|
names.addAll(asList(target.names));
|
||||||
}
|
}
|
||||||
|
|
||||||
return names.toArray(new String[0]);
|
return names.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,27 +53,23 @@ public class SetCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
String arg = args.has() ? args.getString().toLowerCase(Locale.US) : "list";
|
String arg = args.has() ? args.getString().toLowerCase(Locale.US) : "list";
|
||||||
|
|
||||||
if (asList("s", "save").contains(arg)) {
|
if (asList("s", "save").contains(arg)) {
|
||||||
SettingsUtil.save(settings);
|
SettingsUtil.save(settings);
|
||||||
logDirect("Settings saved");
|
logDirect("Settings saved");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean viewModified = asList("m", "mod", "modified").contains(arg);
|
boolean viewModified = asList("m", "mod", "modified").contains(arg);
|
||||||
boolean viewAll = asList("all", "l", "list").contains(arg);
|
boolean viewAll = asList("all", "l", "list").contains(arg);
|
||||||
boolean paginate = viewModified || viewAll;
|
boolean paginate = viewModified || viewAll;
|
||||||
if (paginate) {
|
if (paginate) {
|
||||||
String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
|
String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
|
|
||||||
List<? extends Settings.Setting> toPaginate =
|
List<? extends Settings.Setting> toPaginate =
|
||||||
(viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
|
(viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
|
||||||
.filter(s -> !s.getName().equals("logger"))
|
.filter(s -> !s.getName().equals("logger"))
|
||||||
.filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US)))
|
.filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US)))
|
||||||
.sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName()))
|
.sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Paginator.paginate(
|
Paginator.paginate(
|
||||||
args,
|
args,
|
||||||
new Paginator<>(toPaginate),
|
new Paginator<>(toPaginate),
|
||||||
@ -88,35 +84,28 @@ public class SetCommand extends Command {
|
|||||||
settingTypeToString(setting)
|
settingTypeToString(setting)
|
||||||
));
|
));
|
||||||
typeComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
typeComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
|
|
||||||
ITextComponent hoverComponent = new TextComponentString("");
|
ITextComponent hoverComponent = new TextComponentString("");
|
||||||
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||||
hoverComponent.appendText(setting.getName());
|
hoverComponent.appendText(setting.getName());
|
||||||
hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting)));
|
hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting)));
|
||||||
hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||||
String commandSuggestion = settings.prefix.value + String.format("set %s ", setting.getName());
|
String commandSuggestion = settings.prefix.value + String.format("set %s ", setting.getName());
|
||||||
|
|
||||||
ITextComponent component = new TextComponentString(setting.getName());
|
ITextComponent component = new TextComponentString(setting.getName());
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(typeComponent);
|
component.appendSibling(typeComponent);
|
||||||
component.getStyle()
|
component.getStyle()
|
||||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
||||||
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion));
|
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion));
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
},
|
},
|
||||||
FORCE_COMMAND_PREFIX + "set " + arg + " " + search
|
FORCE_COMMAND_PREFIX + "set " + arg + " " + search
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
|
|
||||||
boolean resetting = arg.equalsIgnoreCase("reset");
|
boolean resetting = arg.equalsIgnoreCase("reset");
|
||||||
boolean toggling = arg.equalsIgnoreCase("toggle");
|
boolean toggling = arg.equalsIgnoreCase("toggle");
|
||||||
boolean doingSomething = resetting || toggling;
|
boolean doingSomething = resetting || toggling;
|
||||||
|
|
||||||
if (resetting) {
|
if (resetting) {
|
||||||
if (!args.has()) {
|
if (!args.has()) {
|
||||||
logDirect("Please specify 'all' as an argument to reset to confirm you'd really like to do this");
|
logDirect("Please specify 'all' as an argument to reset to confirm you'd really like to do this");
|
||||||
@ -126,41 +115,33 @@ public class SetCommand extends Command {
|
|||||||
SettingsUtil.modifiedSettings(settings).forEach(Settings.Setting::reset);
|
SettingsUtil.modifiedSettings(settings).forEach(Settings.Setting::reset);
|
||||||
logDirect("All settings have been reset to their default values");
|
logDirect("All settings have been reset to their default values");
|
||||||
SettingsUtil.save(settings);
|
SettingsUtil.save(settings);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toggling) {
|
if (toggling) {
|
||||||
args.requireMin(1);
|
args.requireMin(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String settingName = doingSomething ? args.getString() : arg;
|
String settingName = doingSomething ? args.getString() : arg;
|
||||||
Settings.Setting<?> setting = settings.allSettings.stream()
|
Settings.Setting<?> setting = settings.allSettings.stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(settingName))
|
.filter(s -> s.getName().equalsIgnoreCase(settingName))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (isNull(setting)) {
|
if (isNull(setting)) {
|
||||||
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doingSomething && !args.has()) {
|
if (!doingSomething && !args.has()) {
|
||||||
logDirect(String.format("Value of setting %s:", setting.getName()));
|
logDirect(String.format("Value of setting %s:", setting.getName()));
|
||||||
logDirect(settingValueToString(setting));
|
logDirect(settingValueToString(setting));
|
||||||
} else {
|
} else {
|
||||||
String oldValue = settingValueToString(setting);
|
String oldValue = settingValueToString(setting);
|
||||||
|
|
||||||
if (resetting) {
|
if (resetting) {
|
||||||
setting.reset();
|
setting.reset();
|
||||||
} else if (toggling) {
|
} else if (toggling) {
|
||||||
if (setting.getValueClass() != Boolean.class) {
|
if (setting.getValueClass() != Boolean.class) {
|
||||||
throw new CommandInvalidTypeException(args.consumed(), "a toggleable setting", "some other setting");
|
throw new CommandInvalidTypeException(args.consumed(), "a toggleable setting", "some other setting");
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
((Settings.Setting<Boolean>) setting).value ^= true;
|
((Settings.Setting<Boolean>) setting).value ^= true;
|
||||||
|
|
||||||
logDirect(String.format(
|
logDirect(String.format(
|
||||||
"Toggled setting %s to %s",
|
"Toggled setting %s to %s",
|
||||||
setting.getName(),
|
setting.getName(),
|
||||||
@ -168,7 +149,6 @@ public class SetCommand extends Command {
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
String newValue = args.getString();
|
String newValue = args.getString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SettingsUtil.parseAndApply(settings, arg, newValue);
|
SettingsUtil.parseAndApply(settings, arg, newValue);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
@ -176,7 +156,6 @@ public class SetCommand extends Command {
|
|||||||
throw new CommandInvalidTypeException(args.consumed(), "a valid value", t);
|
throw new CommandInvalidTypeException(args.consumed(), "a valid value", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!toggling) {
|
if (!toggling) {
|
||||||
logDirect(String.format(
|
logDirect(String.format(
|
||||||
"Successfully %s %s to %s",
|
"Successfully %s %s to %s",
|
||||||
@ -185,7 +164,6 @@ public class SetCommand extends Command {
|
|||||||
settingValueToString(setting)
|
settingValueToString(setting)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextComponent oldValueComponent = new TextComponentString(String.format("Old value: %s", oldValue));
|
ITextComponent oldValueComponent = new TextComponentString(String.format("Old value: %s", oldValue));
|
||||||
oldValueComponent.getStyle()
|
oldValueComponent.getStyle()
|
||||||
.setColor(TextFormatting.GRAY)
|
.setColor(TextFormatting.GRAY)
|
||||||
@ -197,9 +175,7 @@ public class SetCommand extends Command {
|
|||||||
ClickEvent.Action.RUN_COMMAND,
|
ClickEvent.Action.RUN_COMMAND,
|
||||||
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
|
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
|
||||||
));
|
));
|
||||||
|
|
||||||
logDirect(oldValueComponent);
|
logDirect(oldValueComponent);
|
||||||
|
|
||||||
if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) ||
|
if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) ||
|
||||||
setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) {
|
setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) {
|
||||||
logDirect("Warning: Chat commands will no longer work. If you want to revert this change, use prefix control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
logDirect("Warning: Chat commands will no longer work. If you want to revert this change, use prefix control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
||||||
@ -207,7 +183,6 @@ public class SetCommand extends Command {
|
|||||||
logDirect("Warning: Prefixed commands will no longer work. If you want to revert this change, use chat control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
logDirect("Warning: Prefixed commands will no longer work. If you want to revert this change, use chat control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsUtil.save(settings);
|
SettingsUtil.save(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +190,6 @@ public class SetCommand extends Command {
|
|||||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
String arg = args.getString();
|
String arg = args.getString();
|
||||||
|
|
||||||
if (args.hasExactlyOne() && !asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) {
|
if (args.hasExactlyOne() && !asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) {
|
||||||
if (arg.equalsIgnoreCase("reset")) {
|
if (arg.equalsIgnoreCase("reset")) {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
@ -229,19 +203,15 @@ public class SetCommand extends Command {
|
|||||||
.filterPrefix(args.getString())
|
.filterPrefix(args.getString())
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
|
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
|
||||||
|
|
||||||
if (nonNull(setting)) {
|
if (nonNull(setting)) {
|
||||||
if (setting.getType() == Boolean.class) {
|
if (setting.getType() == Boolean.class) {
|
||||||
TabCompleteHelper helper = new TabCompleteHelper();
|
TabCompleteHelper helper = new TabCompleteHelper();
|
||||||
|
|
||||||
if ((Boolean) setting.value) {
|
if ((Boolean) setting.value) {
|
||||||
helper.append(of("true", "false"));
|
helper.append(of("true", "false"));
|
||||||
} else {
|
} else {
|
||||||
helper.append(of("false", "true"));
|
helper.append(of("false", "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper.filterPrefix(args.getString()).stream();
|
return helper.filterPrefix(args.getString()).stream();
|
||||||
} else {
|
} else {
|
||||||
return Stream.of(settingValueToString(setting));
|
return Stream.of(settingValueToString(setting));
|
||||||
@ -256,7 +226,6 @@ public class SetCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,11 @@ public class ThisWayCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireExactly(1);
|
args.requireExactly(1);
|
||||||
|
|
||||||
GoalXZ goal = GoalXZ.fromDirection(
|
GoalXZ goal = GoalXZ.fromDirection(
|
||||||
ctx.playerFeetAsVec(),
|
ctx.playerFeetAsVec(),
|
||||||
ctx.player().rotationYawHead,
|
ctx.player().rotationYawHead,
|
||||||
args.getAs(Double.class)
|
args.getAs(Double.class)
|
||||||
);
|
);
|
||||||
|
|
||||||
baritone.getCustomGoalProcess().setGoal(goal);
|
baritone.getCustomGoalProcess().setGoal(goal);
|
||||||
logDirect(String.format("Goal: %s", goal));
|
logDirect(String.format("Goal: %s", goal));
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,10 @@ public class TunnelCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
Goal goal = new GoalStrictDirection(
|
Goal goal = new GoalStrictDirection(
|
||||||
ctx.playerFeet(),
|
ctx.playerFeet(),
|
||||||
ctx.player().getHorizontalFacing()
|
ctx.player().getHorizontalFacing()
|
||||||
);
|
);
|
||||||
|
|
||||||
baritone.getCustomGoalProcess().setGoal(goal);
|
baritone.getCustomGoalProcess().setGoal(goal);
|
||||||
logDirect(String.format("Goal: %s", goal.toString()));
|
logDirect(String.format("Goal: %s", goal.toString()));
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,7 @@ public class VersionCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
String version = getClass().getPackage().getImplementationVersion();
|
String version = getClass().getPackage().getImplementationVersion();
|
||||||
|
|
||||||
if (isNull(version)) {
|
if (isNull(version)) {
|
||||||
throw new CommandInvalidStateException("Null version (this is normal in a dev environment)");
|
throw new CommandInvalidStateException("Null version (this is normal in a dev environment)");
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,14 +58,11 @@ public class WaypointsCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
Action action = args.has() ? Action.getByName(args.getString()) : Action.LIST;
|
Action action = args.has() ? Action.getByName(args.getString()) : Action.LIST;
|
||||||
|
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||||
}
|
}
|
||||||
|
|
||||||
BiFunction<IWaypoint, Action, ITextComponent> toComponent = (waypoint, _action) -> {
|
BiFunction<IWaypoint, Action, ITextComponent> toComponent = (waypoint, _action) -> {
|
||||||
ITextComponent component = new TextComponentString("");
|
ITextComponent component = new TextComponentString("");
|
||||||
|
|
||||||
ITextComponent tagComponent = new TextComponentString(waypoint.getTag().name() + " ");
|
ITextComponent tagComponent = new TextComponentString(waypoint.getTag().name() + " ");
|
||||||
tagComponent.getStyle().setColor(TextFormatting.GRAY);
|
tagComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||||
String name = waypoint.getName();
|
String name = waypoint.getName();
|
||||||
@ -73,7 +70,6 @@ public class WaypointsCommand extends Command {
|
|||||||
nameComponent.getStyle().setColor(!name.isEmpty() ? TextFormatting.GRAY : TextFormatting.DARK_GRAY);
|
nameComponent.getStyle().setColor(!name.isEmpty() ? TextFormatting.GRAY : TextFormatting.DARK_GRAY);
|
||||||
ITextComponent timestamp = new TextComponentString(" @ " + new Date(waypoint.getCreationTimestamp()));
|
ITextComponent timestamp = new TextComponentString(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||||
timestamp.getStyle().setColor(TextFormatting.DARK_GRAY);
|
timestamp.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
|
|
||||||
component.appendSibling(tagComponent);
|
component.appendSibling(tagComponent);
|
||||||
component.appendSibling(nameComponent);
|
component.appendSibling(nameComponent);
|
||||||
component.appendSibling(timestamp);
|
component.appendSibling(timestamp);
|
||||||
@ -93,24 +89,18 @@ public class WaypointsCommand extends Command {
|
|||||||
waypoint.getCreationTimestamp()
|
waypoint.getCreationTimestamp()
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
};
|
};
|
||||||
|
|
||||||
Function<IWaypoint, ITextComponent> transform = waypoint ->
|
Function<IWaypoint, ITextComponent> transform = waypoint ->
|
||||||
toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action);
|
toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action);
|
||||||
|
|
||||||
if (action == Action.LIST) {
|
if (action == Action.LIST) {
|
||||||
IWaypoint.Tag tag = args.has() ? IWaypoint.Tag.getByName(args.peekString()) : null;
|
IWaypoint.Tag tag = args.has() ? IWaypoint.Tag.getByName(args.peekString()) : null;
|
||||||
|
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
args.get();
|
args.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
IWaypoint[] waypoints = tag != null
|
IWaypoint[] waypoints = tag != null
|
||||||
? ForWaypoints.getWaypointsByTag(tag)
|
? ForWaypoints.getWaypointsByTag(tag)
|
||||||
: ForWaypoints.getWaypoints();
|
: ForWaypoints.getWaypoints();
|
||||||
|
|
||||||
if (waypoints.length > 0) {
|
if (waypoints.length > 0) {
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
Paginator.paginate(
|
Paginator.paginate(
|
||||||
@ -140,21 +130,16 @@ public class WaypointsCommand extends Command {
|
|||||||
}
|
}
|
||||||
} else if (action == Action.SAVE) {
|
} else if (action == Action.SAVE) {
|
||||||
IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString());
|
IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString());
|
||||||
|
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString()));
|
throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = args.has() ? args.getString() : "";
|
String name = args.has() ? args.getString() : "";
|
||||||
BetterBlockPos pos = args.has()
|
BetterBlockPos pos = args.has()
|
||||||
? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet())
|
? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet())
|
||||||
: ctx.playerFeet();
|
: ctx.playerFeet();
|
||||||
|
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
|
|
||||||
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
||||||
ForWaypoints.waypoints().addWaypoint(waypoint);
|
ForWaypoints.waypoints().addWaypoint(waypoint);
|
||||||
|
|
||||||
ITextComponent component = new TextComponentString("Waypoint added: ");
|
ITextComponent component = new TextComponentString("Waypoint added: ");
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(toComponent.apply(waypoint, Action.INFO));
|
component.appendSibling(toComponent.apply(waypoint, Action.INFO));
|
||||||
@ -163,28 +148,23 @@ public class WaypointsCommand extends Command {
|
|||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString());
|
IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString());
|
||||||
IWaypoint[] waypoints = ForWaypoints.getWaypointsByTag(tag);
|
IWaypoint[] waypoints = ForWaypoints.getWaypointsByTag(tag);
|
||||||
|
|
||||||
for (IWaypoint waypoint : waypoints) {
|
for (IWaypoint waypoint : waypoints) {
|
||||||
ForWaypoints.waypoints().removeWaypoint(waypoint);
|
ForWaypoints.waypoints().removeWaypoint(waypoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
logDirect(String.format("Cleared %d waypoints", waypoints.length));
|
logDirect(String.format("Cleared %d waypoints", waypoints.length));
|
||||||
} else {
|
} else {
|
||||||
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.class);
|
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.class);
|
||||||
IWaypoint waypoint = null;
|
IWaypoint waypoint = null;
|
||||||
|
|
||||||
if (args.has() && args.peekString().equals("@")) {
|
if (args.has() && args.peekString().equals("@")) {
|
||||||
args.requireExactly(2);
|
args.requireExactly(2);
|
||||||
args.get();
|
args.get();
|
||||||
long timestamp = args.getAs(Long.class);
|
long timestamp = args.getAs(Long.class);
|
||||||
|
|
||||||
for (IWaypoint iWaypoint : waypoints) {
|
for (IWaypoint iWaypoint : waypoints) {
|
||||||
if (iWaypoint.getCreationTimestamp() == timestamp) {
|
if (iWaypoint.getCreationTimestamp() == timestamp) {
|
||||||
waypoint = iWaypoint;
|
waypoint = iWaypoint;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found");
|
throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found");
|
||||||
}
|
}
|
||||||
@ -196,7 +176,6 @@ public class WaypointsCommand extends Command {
|
|||||||
waypoint = waypoints[0];
|
waypoint = waypoints[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
Paginator.paginate(
|
Paginator.paginate(
|
||||||
@ -273,7 +252,6 @@ public class WaypointsCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
} else {
|
} else {
|
||||||
Action action = Action.getByName(args.getString());
|
Action action = Action.getByName(args.getString());
|
||||||
|
|
||||||
if (args.hasExactlyOne()) {
|
if (args.hasExactlyOne()) {
|
||||||
if (action == Action.LIST || action == Action.SAVE || action == Action.CLEAR) {
|
if (action == Action.LIST || action == Action.SAVE || action == Action.CLEAR) {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
@ -291,7 +269,6 @@ public class WaypointsCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +304,6 @@ public class WaypointsCommand extends Command {
|
|||||||
INFO("info", "show", "i"),
|
INFO("info", "show", "i"),
|
||||||
DELETE("delete", "d"),
|
DELETE("delete", "d"),
|
||||||
GOAL("goal", "goto", "g");
|
GOAL("goal", "goto", "g");
|
||||||
|
|
||||||
private final String[] names;
|
private final String[] names;
|
||||||
|
|
||||||
Action(String... names) {
|
Action(String... names) {
|
||||||
@ -342,17 +318,14 @@ public class WaypointsCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getAllNames() {
|
public static String[] getAllNames() {
|
||||||
Set<String> names = new HashSet<>();
|
Set<String> names = new HashSet<>();
|
||||||
|
|
||||||
for (Action action : Action.values()) {
|
for (Action action : Action.values()) {
|
||||||
names.addAll(asList(action.names));
|
names.addAll(asList(action.names));
|
||||||
}
|
}
|
||||||
|
|
||||||
return names.toArray(new String[0]);
|
return names.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class SchematicAdapter implements ISchematic {
|
public final class SchematicAdapter implements ISchematic {
|
||||||
|
|
||||||
private final SchematicWorld schematic;
|
private final SchematicWorld schematic;
|
||||||
|
|
||||||
public SchematicAdapter(SchematicWorld schematicWorld) {
|
public SchematicAdapter(SchematicWorld schematicWorld) {
|
||||||
|
@ -20,6 +20,7 @@ package com.github.lunatrius.core.util.math;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class MBlockPos extends BlockPos {
|
public class MBlockPos extends BlockPos {
|
||||||
|
|
||||||
MBlockPos() {
|
MBlockPos() {
|
||||||
super(6, 6, 6);
|
super(6, 6, 6);
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,6 @@ package com.github.lunatrius.schematica;
|
|||||||
import com.github.lunatrius.schematica.proxy.CommonProxy;
|
import com.github.lunatrius.schematica.proxy.CommonProxy;
|
||||||
|
|
||||||
public class Schematica {
|
public class Schematica {
|
||||||
|
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public interface ISchematic {
|
public interface ISchematic {
|
||||||
|
|
||||||
IBlockState getBlockState(BlockPos var1);
|
IBlockState getBlockState(BlockPos var1);
|
||||||
|
|
||||||
int getWidth();
|
int getWidth();
|
||||||
|
@ -21,6 +21,7 @@ import com.github.lunatrius.core.util.math.MBlockPos;
|
|||||||
import com.github.lunatrius.schematica.api.ISchematic;
|
import com.github.lunatrius.schematica.api.ISchematic;
|
||||||
|
|
||||||
public class SchematicWorld {
|
public class SchematicWorld {
|
||||||
|
|
||||||
public final MBlockPos position = (MBlockPos) (Object) "cringe";
|
public final MBlockPos position = (MBlockPos) (Object) "cringe";
|
||||||
|
|
||||||
public ISchematic getSchematic() {
|
public ISchematic getSchematic() {
|
||||||
|
@ -20,5 +20,6 @@ package com.github.lunatrius.schematica.proxy;
|
|||||||
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
|
|
||||||
public static SchematicWorld schematic;
|
public static SchematicWorld schematic;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user