Checked Command Exceptions
This commit is contained in:
@@ -22,6 +22,7 @@ import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalAxis;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -35,7 +36,7 @@ public class AxisCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
Goal goal = new GoalAxis();
|
||||
baritone.getCustomGoalProcess().setGoal(goal);
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class BlacklistCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
||||
if (!proc.isActive()) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.datatypes.RelativeFile;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -42,14 +43,14 @@ public class BuildCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
File file = args.getDatatypePost(RelativeFile.class, schematicsDir).getAbsoluteFile();
|
||||
if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
BetterBlockPos buildOrigin;
|
||||
if (args.has()) {
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(3);
|
||||
buildOrigin = args.getDatatype(RelativeBlockPos.class).apply(origin);
|
||||
} else {
|
||||
@@ -64,7 +65,7 @@ public class BuildCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasExactlyOne()) {
|
||||
return RelativeFile.tabComplete(args, schematicsDir);
|
||||
} else if (args.has(2)) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class CancelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getPathingBehavior().cancelEverything();
|
||||
logDirect("ok canceled");
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.Settings;
|
||||
import baritone.api.cache.IRememberedInventory;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -41,7 +42,7 @@ public class ChestsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
Set<Map.Entry<BlockPos, IRememberedInventory>> entries =
|
||||
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
|
||||
|
||||
@@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -38,10 +39,10 @@ public class ClearareaCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
BetterBlockPos pos1 = ctx.playerFeet();
|
||||
BetterBlockPos pos2;
|
||||
if (args.has()) {
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(3);
|
||||
pos2 = args.getDatatype(RelativeBlockPos.class).apply(pos1);
|
||||
} else {
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class ClickCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.openClick();
|
||||
logDirect("aight dude");
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -37,7 +38,7 @@ public class ComeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
Entity entity = mc.getRenderViewEntity();
|
||||
if (entity == null) {
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class EmptyCommand extends Command {
|
||||
|
||||
public EmptyCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("name1", "name2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Short description";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"",
|
||||
"",
|
||||
"Usage:",
|
||||
"> "
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoalXZ;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -35,13 +36,13 @@ public class ExploreCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasAny()) {
|
||||
args.requireExactly(2);
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
}
|
||||
GoalXZ goal = args.has()
|
||||
GoalXZ goal = args.hasAny()
|
||||
? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet())
|
||||
: new GoalXZ(ctx.playerFeet());
|
||||
baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeFile;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
@@ -39,11 +40,11 @@ public class ExploreFilterCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(2);
|
||||
File file = args.getDatatypePost(RelativeFile.class, mc.gameDir.getAbsoluteFile().getParentFile());
|
||||
boolean invert = false;
|
||||
if (args.has()) {
|
||||
if (args.hasAny()) {
|
||||
if (args.getString().equalsIgnoreCase("invert")) {
|
||||
invert = true;
|
||||
} else {
|
||||
@@ -63,7 +64,7 @@ public class ExploreFilterCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasExactlyOne()) {
|
||||
return RelativeFile.tabComplete(args, RelativeFile.gameDir());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class FarmCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getFarmProcess().farm();
|
||||
logDirect("Farming");
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.Settings;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.BlockById;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -37,9 +38,9 @@ public class FindCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
List<Block> toFind = new ArrayList<>();
|
||||
while (args.has()) {
|
||||
while (args.hasAny()) {
|
||||
toFind.add(args.getDatatypeFor(BlockById.class));
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
|
||||
@@ -24,6 +24,7 @@ import baritone.api.utils.command.datatypes.EntityClassById;
|
||||
import baritone.api.utils.command.datatypes.IDatatype;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.utils.command.datatypes.PlayerByUsername;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -43,7 +44,7 @@ public class FollowCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMin(1);
|
||||
FollowGroup group;
|
||||
FollowList list;
|
||||
@@ -55,7 +56,7 @@ public class FollowCommand extends Command {
|
||||
args.requireMin(2);
|
||||
group = null;
|
||||
list = args.getEnum(FollowList.class);
|
||||
while (args.has()) {
|
||||
while (args.hasAny()) {
|
||||
//noinspection unchecked
|
||||
Object gotten = args.getDatatypeFor(list.datatype);
|
||||
if (gotten instanceof Class) {
|
||||
@@ -90,7 +91,7 @@ public class FollowCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(FollowGroup.class)
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,7 +35,7 @@ public class ForceCancelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||
pathingBehavior.cancelEverything();
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class GcCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
System.gc();
|
||||
logDirect("ok called System.gc()");
|
||||
|
||||
@@ -25,6 +25,7 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoal;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
|
||||
@@ -39,9 +40,9 @@ public class GoalCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
||||
if (args.has() && Arrays.asList("reset", "clear", "none").contains(args.peekString())) {
|
||||
if (args.hasAny() && Arrays.asList("reset", "clear", "none").contains(args.peekString())) {
|
||||
args.requireMax(1);
|
||||
if (goalProcess.getGoal() != null) {
|
||||
goalProcess.setGoal(null);
|
||||
@@ -59,7 +60,7 @@ public class GoalCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
TabCompleteHelper helper = new TabCompleteHelper();
|
||||
if (args.hasExactlyOne()) {
|
||||
helper.append(Stream.of("reset", "clear", "none", "~"));
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandNotFoundException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
@@ -46,9 +47,9 @@ public class HelpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(1);
|
||||
if (!args.has() || args.is(Integer.class)) {
|
||||
if (!args.hasAny() || args.is(Integer.class)) {
|
||||
Paginator.paginate(
|
||||
args, new Paginator<>(
|
||||
CommandManager.REGISTRY.descendingStream()
|
||||
@@ -99,7 +100,7 @@ public class HelpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalInverted;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class InvertCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
Goal goal;
|
||||
|
||||
@@ -23,6 +23,7 @@ import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.BlockById;
|
||||
import baritone.api.utils.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
@@ -38,11 +39,11 @@ public class MineCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
int quantity = args.getAsOrDefault(Integer.class, 0);
|
||||
args.requireMin(1);
|
||||
List<BlockOptionalMeta> boms = new ArrayList<>();
|
||||
while (args.has()) {
|
||||
while (args.hasAny()) {
|
||||
boms.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
||||
}
|
||||
WorldScanner.INSTANCE.repack(ctx);
|
||||
|
||||
@@ -24,6 +24,7 @@ import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoal;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
@@ -40,10 +41,10 @@ public class PathCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
Goal goal;
|
||||
if (args.has()) {
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(3);
|
||||
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
||||
} else if ((goal = customGoalProcess.getGoal()) == null) {
|
||||
@@ -56,8 +57,8 @@ public class PathCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has() && !args.has(4)) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasAny() && !args.has(4)) {
|
||||
while (args.has(2)) {
|
||||
if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) {
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,7 @@ import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class PauseResumeCommands {
|
||||
);
|
||||
pauseCommand = new Command(baritone, "pause") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
if (paused[0]) {
|
||||
throw new CommandInvalidStateException("Already paused");
|
||||
@@ -114,7 +115,7 @@ public class PauseResumeCommands {
|
||||
};
|
||||
resumeCommand = new Command(baritone, "resume") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
if (!paused[0]) {
|
||||
throw new CommandInvalidStateException("Not paused");
|
||||
@@ -145,7 +146,7 @@ public class PauseResumeCommands {
|
||||
};
|
||||
pausedCommand = new Command(baritone, "paused") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not "));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class ProcCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
||||
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class ReloadAllCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
ctx.worldData().getCachedWorld().reloadAllFromDisk();
|
||||
logDirect("Reloaded");
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,7 +35,7 @@ public class RenderCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
int renderDistance = (mc.gameSettings.renderDistanceChunks + 1) * 16;
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
@@ -34,7 +35,7 @@ public class RepackCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
logDirect(String.format("Queued %d chunks for repacking", WorldScanner.INSTANCE.repack(ctx)));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class SaveAllCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
ctx.worldData().getCachedWorld().save();
|
||||
logDirect("Saved");
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +34,7 @@ public class SchematicaCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getBuilderProcess().buildOpenSchematic();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.utils.command.datatypes.ForEnumFacing;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
@@ -75,7 +76,7 @@ public class SelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
Action action = Action.getByName(args.getString());
|
||||
if (action == null) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
@@ -85,7 +86,7 @@ public class SelCommand extends Command {
|
||||
throw new CommandInvalidStateException("Set pos1 first before using pos2");
|
||||
}
|
||||
BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(new BlockPos(mc.getRenderViewEntity())) : ctx.playerFeet();
|
||||
BetterBlockPos pos = args.has() ? args.getDatatypePost(RelativeBlockPos.class, playerPos) : playerPos;
|
||||
BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.class, playerPos) : playerPos;
|
||||
args.requireMax(0);
|
||||
if (action == Action.POS1) {
|
||||
pos1 = pos;
|
||||
@@ -186,7 +187,7 @@ public class SelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(Action.getAllNames())
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
@@ -48,8 +49,8 @@ public class SetCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
String arg = args.has() ? args.getString().toLowerCase(Locale.US) : "list";
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
String arg = args.hasAny() ? args.getString().toLowerCase(Locale.US) : "list";
|
||||
if (Arrays.asList("s", "save").contains(arg)) {
|
||||
SettingsUtil.save(settings);
|
||||
logDirect("Settings saved");
|
||||
@@ -59,7 +60,7 @@ public class SetCommand extends Command {
|
||||
boolean viewAll = Arrays.asList("all", "l", "list").contains(arg);
|
||||
boolean paginate = viewModified || viewAll;
|
||||
if (paginate) {
|
||||
String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
|
||||
String search = args.hasAny() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
|
||||
args.requireMax(1);
|
||||
List<? extends Settings.Setting> toPaginate =
|
||||
(viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
|
||||
@@ -104,7 +105,7 @@ public class SetCommand extends Command {
|
||||
boolean toggling = arg.equalsIgnoreCase("toggle");
|
||||
boolean doingSomething = resetting || toggling;
|
||||
if (resetting) {
|
||||
if (!args.has()) {
|
||||
if (!args.hasAny()) {
|
||||
logDirect("Please specify 'all' as an argument to reset to confirm you'd really like to do this");
|
||||
logDirect("ALL settings will be reset. Use the 'set modified' or 'modified' commands to see what will be reset.");
|
||||
logDirect("Specify a setting name instead of 'all' to only reset one setting");
|
||||
@@ -126,7 +127,7 @@ public class SetCommand extends Command {
|
||||
if (setting == null) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
||||
}
|
||||
if (!doingSomething && !args.has()) {
|
||||
if (!doingSomething && !args.hasAny()) {
|
||||
logDirect(String.format("Value of setting %s:", setting.getName()));
|
||||
logDirect(settingValueToString(setting));
|
||||
} else {
|
||||
@@ -184,8 +185,8 @@ public class SetCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasAny()) {
|
||||
String arg = args.getString();
|
||||
if (args.hasExactlyOne() && !Arrays.asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) {
|
||||
if (arg.equalsIgnoreCase("reset")) {
|
||||
@@ -214,7 +215,7 @@ public class SetCommand extends Command {
|
||||
return Stream.of(settingValueToString(setting));
|
||||
}
|
||||
}
|
||||
} else if (!args.has()) {
|
||||
} else if (!args.hasAny()) {
|
||||
return new TabCompleteHelper()
|
||||
.addSettings()
|
||||
.sortAlphabetically()
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,7 +35,7 @@ public class ThisWayCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireExactly(1);
|
||||
GoalXZ goal = GoalXZ.fromDirection(
|
||||
ctx.playerFeetAsVec(),
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalStrictDirection;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -35,7 +36,7 @@ public class TunnelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
Goal goal = new GoalStrictDirection(
|
||||
ctx.playerFeet(),
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.utils.command.defaults;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
@@ -34,7 +35,7 @@ public class VersionCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
args.requireMax(0);
|
||||
String version = getClass().getPackage().getImplementationVersion();
|
||||
if (version == null) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.ForWaypoints;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
@@ -52,8 +53,8 @@ public class WaypointsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
Action action = args.has() ? Action.getByName(args.getString()) : Action.LIST;
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
Action action = args.hasAny() ? Action.getByName(args.getString()) : Action.LIST;
|
||||
if (action == null) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
@@ -90,7 +91,7 @@ public class WaypointsCommand extends Command {
|
||||
Function<IWaypoint, ITextComponent> transform = waypoint ->
|
||||
toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action);
|
||||
if (action == Action.LIST) {
|
||||
IWaypoint.Tag tag = args.has() ? IWaypoint.Tag.getByName(args.peekString()) : null;
|
||||
IWaypoint.Tag tag = args.hasAny() ? IWaypoint.Tag.getByName(args.peekString()) : null;
|
||||
if (tag != null) {
|
||||
args.get();
|
||||
}
|
||||
@@ -129,8 +130,8 @@ public class WaypointsCommand extends Command {
|
||||
if (tag == null) {
|
||||
throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString()));
|
||||
}
|
||||
String name = args.has() ? args.getString() : "";
|
||||
BetterBlockPos pos = args.has()
|
||||
String name = args.hasAny() ? args.getString() : "";
|
||||
BetterBlockPos pos = args.hasAny()
|
||||
? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet())
|
||||
: ctx.playerFeet();
|
||||
args.requireMax(0);
|
||||
@@ -151,7 +152,7 @@ public class WaypointsCommand extends Command {
|
||||
} else {
|
||||
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.class);
|
||||
IWaypoint waypoint = null;
|
||||
if (args.has() && args.peekString().equals("@")) {
|
||||
if (args.hasAny() && args.peekString().equals("@")) {
|
||||
args.requireExactly(2);
|
||||
args.get();
|
||||
long timestamp = args.getAs(Long.class);
|
||||
@@ -241,8 +242,8 @@ public class WaypointsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
|
||||
if (args.hasAny()) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(Action.getAllNames())
|
||||
|
||||
Reference in New Issue
Block a user