From ea4f34cb0ff4e57725649a97f67d31a75954d0aa Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 21 Sep 2019 02:07:10 -0500 Subject: [PATCH] No more passing Settings to execute and tabComplete --- .../baritone/api/utils/command/Command.java | 9 ++++--- .../command/execution/CommandExecution.java | 6 ++--- .../utils/command/defaults/AxisCommand.java | 4 +-- .../command/defaults/BlacklistCommand.java | 4 +-- .../utils/command/defaults/BuildCommand.java | 4 +-- .../utils/command/defaults/CancelCommand.java | 4 +-- .../utils/command/defaults/ChestsCommand.java | 4 +-- .../command/defaults/ClearareaCommand.java | 4 +-- .../utils/command/defaults/ClickCommand.java | 4 +-- .../utils/command/defaults/ComeCommand.java | 4 +-- .../utils/command/defaults/CommandAlias.java | 4 +-- .../command/defaults/ExploreCommand.java | 4 +-- .../defaults/ExploreFilterCommand.java | 4 +-- .../utils/command/defaults/FarmCommand.java | 4 +-- .../utils/command/defaults/FindCommand.java | 4 +-- .../utils/command/defaults/FollowCommand.java | 4 +-- .../command/defaults/ForceCancelCommand.java | 4 +-- .../utils/command/defaults/GcCommand.java | 4 +-- .../utils/command/defaults/GoalCommand.java | 4 +-- .../utils/command/defaults/HelpCommand.java | 4 +-- .../utils/command/defaults/InvertCommand.java | 4 +-- .../utils/command/defaults/MineCommand.java | 4 +-- .../utils/command/defaults/PathCommand.java | 4 +-- .../command/defaults/PauseResumeCommands.java | 14 +++++----- .../utils/command/defaults/ProcCommand.java | 4 +-- .../command/defaults/ReloadAllCommand.java | 4 +-- .../utils/command/defaults/RenderCommand.java | 4 +-- .../utils/command/defaults/RepackCommand.java | 4 +-- .../command/defaults/SaveAllCommand.java | 4 +-- .../command/defaults/SchematicaCommand.java | 4 +-- .../utils/command/defaults/SelCommand.java | 4 +-- .../utils/command/defaults/SetCommand.java | 27 ++++++++++--------- .../command/defaults/ThisWayCommand.java | 4 +-- .../utils/command/defaults/TunnelCommand.java | 4 +-- .../command/defaults/VersionCommand.java | 4 +-- .../command/defaults/WaypointsCommand.java | 4 +-- 36 files changed, 91 insertions(+), 93 deletions(-) diff --git a/src/api/java/baritone/api/utils/command/Command.java b/src/api/java/baritone/api/utils/command/Command.java index 1d198c9a..6b922687 100644 --- a/src/api/java/baritone/api/utils/command/Command.java +++ b/src/api/java/baritone/api/utils/command/Command.java @@ -35,6 +35,7 @@ public abstract class Command implements Helper { protected IBaritone baritone; protected IPlayerContext ctx; + /** * The names of this command. This is what you put after the command prefix. */ @@ -63,7 +64,7 @@ public abstract class Command implements Helper { * @param execution The command execution to execute this command with */ public void execute(CommandExecution execution) throws CommandException { - executed(execution.label, execution.args, execution.settings); + executed(execution.label, execution.args); } /** @@ -74,7 +75,7 @@ public abstract class Command implements Helper { */ public Stream tabComplete(CommandExecution execution) { try { - return tabCompleted(execution.label, execution.args, execution.settings); + return tabCompleted(execution.label, execution.args); } catch (Throwable t) { return Stream.empty(); } @@ -83,13 +84,13 @@ public abstract class Command implements Helper { /** * Called when this command is executed. */ - protected abstract void executed(String label, ArgConsumer args, Settings settings) throws CommandException; + protected abstract void executed(String label, ArgConsumer args) throws CommandException; /** * Called when the command needs to tab complete. Return a Stream representing the entries to put in the completions * list. */ - protected abstract Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException; + protected abstract Stream tabCompleted(String label, ArgConsumer args) throws CommandException; /** * @return A single-line string containing a short description of this command's purpose. diff --git a/src/api/java/baritone/api/utils/command/execution/CommandExecution.java b/src/api/java/baritone/api/utils/command/execution/CommandExecution.java index b82926e4..dc25d32c 100644 --- a/src/api/java/baritone/api/utils/command/execution/CommandExecution.java +++ b/src/api/java/baritone/api/utils/command/execution/CommandExecution.java @@ -36,18 +36,16 @@ public class CommandExecution { * The command itself */ private final Command command; + /** * The name this command was called with */ public final String label; + /** * The arg consumer */ public final ArgConsumer args; - /** - * The Baritone settings - */ - public final Settings settings = BaritoneAPI.getSettings(); public CommandExecution(Command command, String label, ArgConsumer args) { this.command = command; diff --git a/src/main/java/baritone/utils/command/defaults/AxisCommand.java b/src/main/java/baritone/utils/command/defaults/AxisCommand.java index 50525f2d..942c829e 100644 --- a/src/main/java/baritone/utils/command/defaults/AxisCommand.java +++ b/src/main/java/baritone/utils/command/defaults/AxisCommand.java @@ -36,7 +36,7 @@ public class AxisCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); Goal goal = new GoalAxis(); baritone.getCustomGoalProcess().setGoal(goal); @@ -44,7 +44,7 @@ public class AxisCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/BlacklistCommand.java b/src/main/java/baritone/utils/command/defaults/BlacklistCommand.java index e680e4fa..915f5b51 100644 --- a/src/main/java/baritone/utils/command/defaults/BlacklistCommand.java +++ b/src/main/java/baritone/utils/command/defaults/BlacklistCommand.java @@ -36,7 +36,7 @@ public class BlacklistCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); IGetToBlockProcess proc = baritone.getGetToBlockProcess(); if (!proc.isActive()) { @@ -50,7 +50,7 @@ public class BlacklistCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/BuildCommand.java b/src/main/java/baritone/utils/command/defaults/BuildCommand.java index 85f51da1..72c065c7 100644 --- a/src/main/java/baritone/utils/command/defaults/BuildCommand.java +++ b/src/main/java/baritone/utils/command/defaults/BuildCommand.java @@ -43,7 +43,7 @@ public class BuildCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { File file = args.getDatatypePost(RelativeFile.class, schematicsDir).getAbsoluteFile(); if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) { file = new File(file.getAbsolutePath() + ".schematic"); @@ -65,7 +65,7 @@ public class BuildCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasExactlyOne()) { return RelativeFile.tabComplete(args, schematicsDir); } else if (args.has(2)) { diff --git a/src/main/java/baritone/utils/command/defaults/CancelCommand.java b/src/main/java/baritone/utils/command/defaults/CancelCommand.java index 55c172b8..45e0854a 100644 --- a/src/main/java/baritone/utils/command/defaults/CancelCommand.java +++ b/src/main/java/baritone/utils/command/defaults/CancelCommand.java @@ -34,14 +34,14 @@ public class CancelCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); baritone.getPathingBehavior().cancelEverything(); logDirect("ok canceled"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/ChestsCommand.java b/src/main/java/baritone/utils/command/defaults/ChestsCommand.java index 8e2cee79..5c0bc354 100644 --- a/src/main/java/baritone/utils/command/defaults/ChestsCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ChestsCommand.java @@ -42,7 +42,7 @@ public class ChestsCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); Set> entries = ctx.worldData().getContainerMemory().getRememberedInventories().entrySet(); @@ -63,7 +63,7 @@ public class ChestsCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/ClearareaCommand.java b/src/main/java/baritone/utils/command/defaults/ClearareaCommand.java index 99f39307..5e404180 100644 --- a/src/main/java/baritone/utils/command/defaults/ClearareaCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ClearareaCommand.java @@ -39,7 +39,7 @@ public class ClearareaCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { BetterBlockPos pos1 = ctx.playerFeet(); BetterBlockPos pos2; if (args.hasAny()) { @@ -59,7 +59,7 @@ public class ClearareaCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return args.tabCompleteDatatype(RelativeBlockPos.class); } diff --git a/src/main/java/baritone/utils/command/defaults/ClickCommand.java b/src/main/java/baritone/utils/command/defaults/ClickCommand.java index 49324d88..23ded82f 100644 --- a/src/main/java/baritone/utils/command/defaults/ClickCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ClickCommand.java @@ -34,14 +34,14 @@ public class ClickCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); baritone.openClick(); logDirect("aight dude"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/ComeCommand.java b/src/main/java/baritone/utils/command/defaults/ComeCommand.java index bf02d75d..399317e5 100644 --- a/src/main/java/baritone/utils/command/defaults/ComeCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ComeCommand.java @@ -38,7 +38,7 @@ public class ComeCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); Entity entity = mc.getRenderViewEntity(); if (entity == null) { @@ -49,7 +49,7 @@ public class ComeCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/CommandAlias.java b/src/main/java/baritone/utils/command/defaults/CommandAlias.java index aba934b2..91dc2a07 100644 --- a/src/main/java/baritone/utils/command/defaults/CommandAlias.java +++ b/src/main/java/baritone/utils/command/defaults/CommandAlias.java @@ -45,12 +45,12 @@ public class CommandAlias extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) { + protected void executed(String label, ArgConsumer args) { CommandManager.execute(String.format("%s %s", target, args.rawRest())); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return CommandManager.tabComplete(String.format("%s %s", target, args.rawRest())); } diff --git a/src/main/java/baritone/utils/command/defaults/ExploreCommand.java b/src/main/java/baritone/utils/command/defaults/ExploreCommand.java index 57b95d59..6f844476 100644 --- a/src/main/java/baritone/utils/command/defaults/ExploreCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ExploreCommand.java @@ -36,7 +36,7 @@ public class ExploreCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { if (args.hasAny()) { args.requireExactly(2); } else { @@ -50,7 +50,7 @@ public class ExploreCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { if (args.hasAtMost(2)) { return args.tabCompleteDatatype(RelativeGoalXZ.class); } diff --git a/src/main/java/baritone/utils/command/defaults/ExploreFilterCommand.java b/src/main/java/baritone/utils/command/defaults/ExploreFilterCommand.java index 338a622c..6deffd22 100644 --- a/src/main/java/baritone/utils/command/defaults/ExploreFilterCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ExploreFilterCommand.java @@ -40,7 +40,7 @@ public class ExploreFilterCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(2); File file = args.getDatatypePost(RelativeFile.class, mc.gameDir.getAbsoluteFile().getParentFile()); boolean invert = false; @@ -64,7 +64,7 @@ public class ExploreFilterCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasExactlyOne()) { return RelativeFile.tabComplete(args, RelativeFile.gameDir()); } diff --git a/src/main/java/baritone/utils/command/defaults/FarmCommand.java b/src/main/java/baritone/utils/command/defaults/FarmCommand.java index af3efa2c..6ff746d4 100644 --- a/src/main/java/baritone/utils/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/utils/command/defaults/FarmCommand.java @@ -34,14 +34,14 @@ public class FarmCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); baritone.getFarmProcess().farm(); logDirect("Farming"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/FindCommand.java b/src/main/java/baritone/utils/command/defaults/FindCommand.java index 552985a4..c5a808dd 100644 --- a/src/main/java/baritone/utils/command/defaults/FindCommand.java +++ b/src/main/java/baritone/utils/command/defaults/FindCommand.java @@ -38,7 +38,7 @@ public class FindCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { List toFind = new ArrayList<>(); while (args.hasAny()) { toFind.add(args.getDatatypeFor(BlockById.class)); @@ -60,7 +60,7 @@ public class FindCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return args.tabCompleteDatatype(BlockById.class); } diff --git a/src/main/java/baritone/utils/command/defaults/FollowCommand.java b/src/main/java/baritone/utils/command/defaults/FollowCommand.java index 46f89d75..b22613b9 100644 --- a/src/main/java/baritone/utils/command/defaults/FollowCommand.java +++ b/src/main/java/baritone/utils/command/defaults/FollowCommand.java @@ -44,7 +44,7 @@ public class FollowCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMin(1); FollowGroup group; FollowList list; @@ -91,7 +91,7 @@ public class FollowCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasExactlyOne()) { return new TabCompleteHelper() .append(FollowGroup.class) diff --git a/src/main/java/baritone/utils/command/defaults/ForceCancelCommand.java b/src/main/java/baritone/utils/command/defaults/ForceCancelCommand.java index 6596749d..5672f9b3 100644 --- a/src/main/java/baritone/utils/command/defaults/ForceCancelCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ForceCancelCommand.java @@ -35,7 +35,7 @@ public class ForceCancelCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); IPathingBehavior pathingBehavior = baritone.getPathingBehavior(); pathingBehavior.cancelEverything(); @@ -44,7 +44,7 @@ public class ForceCancelCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/GcCommand.java b/src/main/java/baritone/utils/command/defaults/GcCommand.java index aa29d667..23bea821 100644 --- a/src/main/java/baritone/utils/command/defaults/GcCommand.java +++ b/src/main/java/baritone/utils/command/defaults/GcCommand.java @@ -34,14 +34,14 @@ public class GcCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); System.gc(); logDirect("ok called System.gc()"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/GoalCommand.java b/src/main/java/baritone/utils/command/defaults/GoalCommand.java index bd50e33e..23065deb 100644 --- a/src/main/java/baritone/utils/command/defaults/GoalCommand.java +++ b/src/main/java/baritone/utils/command/defaults/GoalCommand.java @@ -40,7 +40,7 @@ public class GoalCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess(); if (args.hasAny() && Arrays.asList("reset", "clear", "none").contains(args.peekString())) { args.requireMax(1); @@ -60,7 +60,7 @@ public class GoalCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { TabCompleteHelper helper = new TabCompleteHelper(); if (args.hasExactlyOne()) { helper.append(Stream.of("reset", "clear", "none", "~")); diff --git a/src/main/java/baritone/utils/command/defaults/HelpCommand.java b/src/main/java/baritone/utils/command/defaults/HelpCommand.java index 6b02fa30..8cdcab71 100644 --- a/src/main/java/baritone/utils/command/defaults/HelpCommand.java +++ b/src/main/java/baritone/utils/command/defaults/HelpCommand.java @@ -47,7 +47,7 @@ public class HelpCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(1); if (!args.hasAny() || args.is(Integer.class)) { Paginator.paginate( @@ -100,7 +100,7 @@ public class HelpCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasExactlyOne()) { return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream(); } diff --git a/src/main/java/baritone/utils/command/defaults/InvertCommand.java b/src/main/java/baritone/utils/command/defaults/InvertCommand.java index 6a8d3f06..60723de2 100644 --- a/src/main/java/baritone/utils/command/defaults/InvertCommand.java +++ b/src/main/java/baritone/utils/command/defaults/InvertCommand.java @@ -38,7 +38,7 @@ public class InvertCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); Goal goal; @@ -55,7 +55,7 @@ public class InvertCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/MineCommand.java b/src/main/java/baritone/utils/command/defaults/MineCommand.java index 473296c9..e1b1f67b 100644 --- a/src/main/java/baritone/utils/command/defaults/MineCommand.java +++ b/src/main/java/baritone/utils/command/defaults/MineCommand.java @@ -39,7 +39,7 @@ public class MineCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { int quantity = args.getAsOrDefault(Integer.class, 0); args.requireMin(1); List boms = new ArrayList<>(); @@ -52,7 +52,7 @@ public class MineCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return args.tabCompleteDatatype(BlockById.class); } diff --git a/src/main/java/baritone/utils/command/defaults/PathCommand.java b/src/main/java/baritone/utils/command/defaults/PathCommand.java index b5972e6b..d1da5957 100644 --- a/src/main/java/baritone/utils/command/defaults/PathCommand.java +++ b/src/main/java/baritone/utils/command/defaults/PathCommand.java @@ -41,7 +41,7 @@ public class PathCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); Goal goal; if (args.hasAny()) { @@ -57,7 +57,7 @@ public class PathCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasAny() && !args.has(4)) { while (args.has(2)) { if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) { diff --git a/src/main/java/baritone/utils/command/defaults/PauseResumeCommands.java b/src/main/java/baritone/utils/command/defaults/PauseResumeCommands.java index 06e91377..ee15fde6 100644 --- a/src/main/java/baritone/utils/command/defaults/PauseResumeCommands.java +++ b/src/main/java/baritone/utils/command/defaults/PauseResumeCommands.java @@ -40,13 +40,11 @@ import java.util.stream.Stream; */ public class PauseResumeCommands { - private final IBaritone baritone; Command pauseCommand; Command resumeCommand; Command pausedCommand; public PauseResumeCommands(IBaritone baritone) { - this.baritone = baritone; // array for mutability, non-field so reflection can't touch it final boolean[] paused = {false}; baritone.getPathingControlManager().registerProcess( @@ -82,7 +80,7 @@ public class PauseResumeCommands { ); pauseCommand = new Command(baritone, "pause") { @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); if (paused[0]) { throw new CommandInvalidStateException("Already paused"); @@ -92,7 +90,7 @@ public class PauseResumeCommands { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } @@ -115,7 +113,7 @@ public class PauseResumeCommands { }; resumeCommand = new Command(baritone, "resume") { @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); if (!paused[0]) { throw new CommandInvalidStateException("Not paused"); @@ -125,7 +123,7 @@ public class PauseResumeCommands { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } @@ -146,13 +144,13 @@ public class PauseResumeCommands { }; pausedCommand = new Command(baritone, "paused") { @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not ")); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/ProcCommand.java b/src/main/java/baritone/utils/command/defaults/ProcCommand.java index 09c0b0c4..063df9be 100644 --- a/src/main/java/baritone/utils/command/defaults/ProcCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ProcCommand.java @@ -38,7 +38,7 @@ public class ProcCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); IPathingControlManager pathingControlManager = baritone.getPathingControlManager(); IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null); @@ -63,7 +63,7 @@ public class ProcCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/ReloadAllCommand.java b/src/main/java/baritone/utils/command/defaults/ReloadAllCommand.java index 877be0b6..0a860ede 100644 --- a/src/main/java/baritone/utils/command/defaults/ReloadAllCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ReloadAllCommand.java @@ -34,14 +34,14 @@ public class ReloadAllCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); ctx.worldData().getCachedWorld().reloadAllFromDisk(); logDirect("Reloaded"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/RenderCommand.java b/src/main/java/baritone/utils/command/defaults/RenderCommand.java index 92aedc43..75cf0a44 100644 --- a/src/main/java/baritone/utils/command/defaults/RenderCommand.java +++ b/src/main/java/baritone/utils/command/defaults/RenderCommand.java @@ -35,7 +35,7 @@ public class RenderCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); BetterBlockPos origin = ctx.playerFeet(); int renderDistance = (mc.gameSettings.renderDistanceChunks + 1) * 16; @@ -51,7 +51,7 @@ public class RenderCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/RepackCommand.java b/src/main/java/baritone/utils/command/defaults/RepackCommand.java index 90c131e9..08503531 100644 --- a/src/main/java/baritone/utils/command/defaults/RepackCommand.java +++ b/src/main/java/baritone/utils/command/defaults/RepackCommand.java @@ -35,13 +35,13 @@ public class RepackCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); logDirect(String.format("Queued %d chunks for repacking", WorldScanner.INSTANCE.repack(ctx))); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/SaveAllCommand.java b/src/main/java/baritone/utils/command/defaults/SaveAllCommand.java index 6729e968..a505dda1 100644 --- a/src/main/java/baritone/utils/command/defaults/SaveAllCommand.java +++ b/src/main/java/baritone/utils/command/defaults/SaveAllCommand.java @@ -34,14 +34,14 @@ public class SaveAllCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); ctx.worldData().getCachedWorld().save(); logDirect("Saved"); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/SchematicaCommand.java b/src/main/java/baritone/utils/command/defaults/SchematicaCommand.java index 53ba4c1d..2a984dd2 100644 --- a/src/main/java/baritone/utils/command/defaults/SchematicaCommand.java +++ b/src/main/java/baritone/utils/command/defaults/SchematicaCommand.java @@ -34,13 +34,13 @@ public class SchematicaCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); baritone.getBuilderProcess().buildOpenSchematic(); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/SelCommand.java b/src/main/java/baritone/utils/command/defaults/SelCommand.java index 7895586b..362fd631 100644 --- a/src/main/java/baritone/utils/command/defaults/SelCommand.java +++ b/src/main/java/baritone/utils/command/defaults/SelCommand.java @@ -76,7 +76,7 @@ public class SelCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { Action action = Action.getByName(args.getString()); if (action == null) { throw new CommandInvalidTypeException(args.consumed(), "an action"); @@ -187,7 +187,7 @@ public class SelCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasExactlyOne()) { return new TabCompleteHelper() .append(Action.getAllNames()) diff --git a/src/main/java/baritone/utils/command/defaults/SetCommand.java b/src/main/java/baritone/utils/command/defaults/SetCommand.java index 294fe0ce..f3baeeb2 100644 --- a/src/main/java/baritone/utils/command/defaults/SetCommand.java +++ b/src/main/java/baritone/utils/command/defaults/SetCommand.java @@ -17,6 +17,7 @@ package baritone.utils.command.defaults; +import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.Settings; import baritone.api.utils.SettingsUtil; @@ -49,10 +50,10 @@ public class SetCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { String arg = args.hasAny() ? args.getString().toLowerCase(Locale.US) : "list"; if (Arrays.asList("s", "save").contains(arg)) { - SettingsUtil.save(settings); + SettingsUtil.save(Baritone.settings()); logDirect("Settings saved"); return; } @@ -63,7 +64,7 @@ public class SetCommand extends Command { String search = args.hasAny() && args.peekAsOrNull(Integer.class) == null ? args.getString() : ""; args.requireMax(1); List toPaginate = - (viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream() + (viewModified ? SettingsUtil.modifiedSettings(Baritone.settings()) : Baritone.settings().allSettings).stream() .filter(s -> !s.getName().equals("logger")) .filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US))) .sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName())) @@ -87,7 +88,7 @@ public class SetCommand extends Command { hoverComponent.appendText(setting.getName()); hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting))); hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting))); - String commandSuggestion = settings.prefix.value + String.format("set %s ", setting.getName()); + String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName()); ITextComponent component = new TextComponentString(setting.getName()); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(typeComponent); @@ -110,9 +111,9 @@ public class SetCommand extends Command { 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"); } else if (args.peekString().equalsIgnoreCase("all")) { - SettingsUtil.modifiedSettings(settings).forEach(Settings.Setting::reset); + SettingsUtil.modifiedSettings(Baritone.settings()).forEach(Settings.Setting::reset); logDirect("All settings have been reset to their default values"); - SettingsUtil.save(settings); + SettingsUtil.save(Baritone.settings()); return; } } @@ -120,7 +121,7 @@ public class SetCommand extends Command { args.requireMin(1); } String settingName = doingSomething ? args.getString() : arg; - Settings.Setting setting = settings.allSettings.stream() + Settings.Setting setting = Baritone.settings().allSettings.stream() .filter(s -> s.getName().equalsIgnoreCase(settingName)) .findFirst() .orElse(null); @@ -148,7 +149,7 @@ public class SetCommand extends Command { } else { String newValue = args.getString(); try { - SettingsUtil.parseAndApply(settings, arg, newValue); + SettingsUtil.parseAndApply(Baritone.settings(), arg, newValue); } catch (Throwable t) { t.printStackTrace(); throw new CommandInvalidTypeException(args.consumed(), "a valid value", t); @@ -174,18 +175,18 @@ public class SetCommand extends Command { FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue) )); logDirect(oldValueComponent); - if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) || - setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) { + if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !Baritone.settings().chatControlAnyway.value) || + setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !Baritone.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); } else if (setting.getName().equals("prefixControl") && !(Boolean) setting.value) { 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(Baritone.settings()); } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasAny()) { String arg = args.getString(); if (args.hasExactlyOne() && !Arrays.asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) { @@ -201,7 +202,7 @@ public class SetCommand extends Command { .filterPrefix(args.getString()) .stream(); } - Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US)); + Settings.Setting setting = Baritone.settings().byLowerName.get(arg.toLowerCase(Locale.US)); if (setting != null) { if (setting.getType() == Boolean.class) { TabCompleteHelper helper = new TabCompleteHelper(); diff --git a/src/main/java/baritone/utils/command/defaults/ThisWayCommand.java b/src/main/java/baritone/utils/command/defaults/ThisWayCommand.java index 2cbde830..384a52cb 100644 --- a/src/main/java/baritone/utils/command/defaults/ThisWayCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ThisWayCommand.java @@ -35,7 +35,7 @@ public class ThisWayCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireExactly(1); GoalXZ goal = GoalXZ.fromDirection( ctx.playerFeetAsVec(), @@ -47,7 +47,7 @@ public class ThisWayCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/TunnelCommand.java b/src/main/java/baritone/utils/command/defaults/TunnelCommand.java index 5f1dca55..5ac21b7a 100644 --- a/src/main/java/baritone/utils/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/utils/command/defaults/TunnelCommand.java @@ -36,7 +36,7 @@ public class TunnelCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); Goal goal = new GoalStrictDirection( ctx.playerFeet(), @@ -47,7 +47,7 @@ public class TunnelCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/VersionCommand.java b/src/main/java/baritone/utils/command/defaults/VersionCommand.java index 80170a42..de09e943 100644 --- a/src/main/java/baritone/utils/command/defaults/VersionCommand.java +++ b/src/main/java/baritone/utils/command/defaults/VersionCommand.java @@ -35,7 +35,7 @@ public class VersionCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { args.requireMax(0); String version = getClass().getPackage().getImplementationVersion(); if (version == null) { @@ -46,7 +46,7 @@ public class VersionCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { + protected Stream tabCompleted(String label, ArgConsumer args) { return Stream.empty(); } diff --git a/src/main/java/baritone/utils/command/defaults/WaypointsCommand.java b/src/main/java/baritone/utils/command/defaults/WaypointsCommand.java index 3af2ebd9..6344117a 100644 --- a/src/main/java/baritone/utils/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/utils/command/defaults/WaypointsCommand.java @@ -53,7 +53,7 @@ public class WaypointsCommand extends Command { } @Override - protected void executed(String label, ArgConsumer args, Settings settings) throws CommandException { + protected void executed(String label, ArgConsumer args) throws CommandException { Action action = args.hasAny() ? Action.getByName(args.getString()) : Action.LIST; if (action == null) { throw new CommandInvalidTypeException(args.consumed(), "an action"); @@ -242,7 +242,7 @@ public class WaypointsCommand extends Command { } @Override - protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException { + protected Stream tabCompleted(String label, ArgConsumer args) throws CommandException { if (args.hasAny()) { if (args.hasExactlyOne()) { return new TabCompleteHelper()