Search in sources :

Example 1 with TabCompleteHelper

use of baritone.api.command.helpers.TabCompleteHelper in project baritone by cabaletta.

the class CommandManager method tabComplete.

@Override
public Stream<String> tabComplete(String prefix) {
    Tuple<String, List<ICommandArgument>> pair = expand(prefix, true);
    String label = pair.getFirst();
    List<ICommandArgument> args = pair.getSecond();
    if (args.isEmpty()) {
        return new TabCompleteHelper().addCommands(this.baritone.getCommandManager()).filterPrefix(label).stream();
    } else {
        return tabComplete(pair);
    }
}
Also used : ICommandArgument(baritone.api.command.argument.ICommandArgument) List(java.util.List) TabCompleteHelper(baritone.api.command.helpers.TabCompleteHelper)

Example 2 with TabCompleteHelper

use of baritone.api.command.helpers.TabCompleteHelper in project Spark-Client by Spark-Client-Development.

the class ExampleBaritoneControl method tabComplete.

public Stream<String> tabComplete(String msg) {
    try {
        List<ICommandArgument> args = CommandArguments.from(msg, true);
        ArgConsumer argc = new ArgConsumer(this.manager, args);
        if (argc.hasAtMost(2)) {
            if (argc.hasExactly(1)) {
                return new TabCompleteHelper().addCommands(this.manager).addSettings().filterPrefix(argc.getString()).stream();
            }
            Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
            if (setting != null) {
                if (setting.getValueClass() == Boolean.class) {
                    TabCompleteHelper helper = new TabCompleteHelper();
                    if ((Boolean) setting.getValue()) {
                        helper.append("true", "false");
                    } else {
                        helper.append("false", "true");
                    }
                    return helper.filterPrefix(argc.getString()).stream();
                } else {
                    return Stream.of(SettingsUtil.settingValueToString(setting));
                }
            }
        }
        return this.manager.tabComplete(msg);
    } catch (CommandNotEnoughArgumentsException ignored) {
        // Shouldn't happen, the operation is safe
        return Stream.empty();
    }
}
Also used : ICommandArgument(baritone.api.command.argument.ICommandArgument) TabCompleteHelper(baritone.api.command.helpers.TabCompleteHelper) ArgConsumer(baritone.command.argument.ArgConsumer) Settings(baritone.api.Settings) CommandNotEnoughArgumentsException(baritone.api.command.exception.CommandNotEnoughArgumentsException)

Example 3 with TabCompleteHelper

use of baritone.api.command.helpers.TabCompleteHelper in project Spark-Client by Spark-Client-Development.

the class CommandManager method tabComplete.

@Override
public Stream<String> tabComplete(String prefix) {
    Tuple<String, List<ICommandArgument>> pair = expand(prefix, true);
    String label = pair.getFirst();
    List<ICommandArgument> args = pair.getSecond();
    if (args.isEmpty()) {
        return new TabCompleteHelper().addCommands(this.baritone.getCommandManager()).filterPrefix(label).stream();
    } else {
        return tabComplete(pair);
    }
}
Also used : ICommandArgument(baritone.api.command.argument.ICommandArgument) List(java.util.List) TabCompleteHelper(baritone.api.command.helpers.TabCompleteHelper)

Example 4 with TabCompleteHelper

use of baritone.api.command.helpers.TabCompleteHelper in project baritone by cabaletta.

the class ExampleBaritoneControl method tabComplete.

public Stream<String> tabComplete(String msg) {
    try {
        List<ICommandArgument> args = CommandArguments.from(msg, true);
        ArgConsumer argc = new ArgConsumer(this.manager, args);
        if (argc.hasAtMost(2)) {
            if (argc.hasExactly(1)) {
                return new TabCompleteHelper().addCommands(this.manager).addSettings().filterPrefix(argc.getString()).stream();
            }
            Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
            if (setting != null && !SettingsUtil.javaOnlySetting(setting)) {
                if (setting.getValueClass() == Boolean.class) {
                    TabCompleteHelper helper = new TabCompleteHelper();
                    if ((Boolean) setting.value) {
                        helper.append("true", "false");
                    } else {
                        helper.append("false", "true");
                    }
                    return helper.filterPrefix(argc.getString()).stream();
                } else {
                    return Stream.of(SettingsUtil.settingValueToString(setting));
                }
            }
        }
        return this.manager.tabComplete(msg);
    } catch (CommandNotEnoughArgumentsException ignored) {
        // Shouldn't happen, the operation is safe
        return Stream.empty();
    }
}
Also used : ICommandArgument(baritone.api.command.argument.ICommandArgument) TabCompleteHelper(baritone.api.command.helpers.TabCompleteHelper) ArgConsumer(baritone.command.argument.ArgConsumer) Settings(baritone.api.Settings) CommandNotEnoughArgumentsException(baritone.api.command.exception.CommandNotEnoughArgumentsException)

Aggregations

ICommandArgument (baritone.api.command.argument.ICommandArgument)4 TabCompleteHelper (baritone.api.command.helpers.TabCompleteHelper)4 Settings (baritone.api.Settings)2 CommandNotEnoughArgumentsException (baritone.api.command.exception.CommandNotEnoughArgumentsException)2 ArgConsumer (baritone.command.argument.ArgConsumer)2 List (java.util.List)2