No more passing Settings to execute and tabComplete

This commit is contained in:
Brady 2019-09-21 02:07:10 -05:00
parent b7eaae88a8
commit ea4f34cb0f
No known key found for this signature in database
GPG Key ID: 73A788379A197567
36 changed files with 91 additions and 93 deletions

View File

@ -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<String> 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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException;
protected abstract Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException;
/**
* @return A <b>single-line</b> string containing a short description of this command's purpose.

View File

@ -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;

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasExactlyOne()) {
return RelativeFile.tabComplete(args, schematicsDir);
} else if (args.has(2)) {

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<Map.Entry<BlockPos, IRememberedInventory>> entries =
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
@ -63,7 +63,7 @@ public class ChestsCommand extends Command {
}
@Override
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return args.tabCompleteDatatype(RelativeBlockPos.class);
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return CommandManager.tabComplete(String.format("%s %s", target, args.rawRest()));
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
if (args.hasAtMost(2)) {
return args.tabCompleteDatatype(RelativeGoalXZ.class);
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasExactlyOne()) {
return RelativeFile.tabComplete(args, RelativeFile.gameDir());
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<Block> toFind = new ArrayList<>();
while (args.hasAny()) {
toFind.add(args.getDatatypeFor(BlockById.class));
@ -60,7 +60,7 @@ public class FindCommand extends Command {
}
@Override
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return args.tabCompleteDatatype(BlockById.class);
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasExactlyOne()) {
return new TabCompleteHelper()
.append(FollowGroup.class)

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
TabCompleteHelper helper = new TabCompleteHelper();
if (args.hasExactlyOne()) {
helper.append(Stream.of("reset", "clear", "none", "~"));

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasExactlyOne()) {
return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<BlockOptionalMeta> boms = new ArrayList<>();
@ -52,7 +52,7 @@ public class MineCommand extends Command {
}
@Override
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return args.tabCompleteDatatype(BlockById.class);
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasAny() && !args.has(4)) {
while (args.has(2)) {
if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) {

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> 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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> 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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasExactlyOne()) {
return new TabCompleteHelper()
.append(Action.getAllNames())

View File

@ -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<? extends Settings.Setting> 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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> 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();

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
return Stream.empty();
}

View File

@ -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<String> tabCompleted(String label, ArgConsumer args, Settings settings) throws CommandException {
protected Stream<String> tabCompleted(String label, ArgConsumer args) throws CommandException {
if (args.hasAny()) {
if (args.hasExactlyOne()) {
return new TabCompleteHelper()