use of baritone.api.command.ICommand in project baritone by cabaletta.
the class HelpCommand method execute.
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(1);
if (!args.hasAny() || args.is(Integer.class)) {
Paginator.paginate(args, new Paginator<>(this.baritone.getCommandManager().getRegistry().descendingStream().filter(command -> !command.hiddenFromHelp()).collect(Collectors.toList())), () -> logDirect("All Baritone commands (clickable):"), command -> {
String names = String.join("/", command.getNames());
String name = command.getNames().get(0);
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
ITextComponent namesComponent = new TextComponentString(names);
namesComponent.getStyle().setColor(TextFormatting.WHITE);
ITextComponent hoverComponent = new TextComponentString("");
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
hoverComponent.appendSibling(namesComponent);
hoverComponent.appendText("\n" + command.getShortDesc());
hoverComponent.appendText("\n\nClick to view full help");
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
ITextComponent component = new TextComponentString(name);
component.getStyle().setColor(TextFormatting.GRAY);
component.appendSibling(shortDescComponent);
component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand));
return component;
}, FORCE_COMMAND_PREFIX + label);
} else {
String commandName = args.getString().toLowerCase();
ICommand command = this.baritone.getCommandManager().getCommand(commandName);
if (command == null) {
throw new CommandNotFoundException(commandName);
}
logDirect(String.format("%s - %s", String.join(" / ", command.getNames()), command.getShortDesc()));
logDirect("");
command.getLongDesc().forEach(this::logDirect);
logDirect("");
ITextComponent returnComponent = new TextComponentString("Click to return to the help menu");
returnComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + label));
logDirect(returnComponent);
}
}
use of baritone.api.command.ICommand in project Spark-Client by Spark-Client-Development.
the class HelpCommand method execute.
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(1);
if (!args.hasAny() || args.is(Integer.class)) {
Paginator.paginate(args, new Paginator<>(this.baritone.getCommandManager().getRegistry().descendingStream().filter(command -> !command.hiddenFromHelp()).collect(Collectors.toList())), () -> logDirect("All Baritone commands (clickable):"), command -> {
String names = String.join("/", command.getNames());
String name = command.getNames().get(0);
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
ITextComponent namesComponent = new TextComponentString(names);
namesComponent.getStyle().setColor(TextFormatting.WHITE);
ITextComponent hoverComponent = new TextComponentString("");
hoverComponent.getStyle().setColor(TextFormatting.GRAY);
hoverComponent.appendSibling(namesComponent);
hoverComponent.appendText("\n" + command.getShortDesc());
hoverComponent.appendText("\n\nClick to view full help");
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
ITextComponent component = new TextComponentString(name);
component.getStyle().setColor(TextFormatting.GRAY);
component.appendSibling(shortDescComponent);
component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand));
return component;
}, FORCE_COMMAND_PREFIX + label);
} else {
String commandName = args.getString().toLowerCase();
ICommand command = this.baritone.getCommandManager().getCommand(commandName);
if (command == null) {
throw new CommandNotFoundException(commandName);
}
logDirect(String.format("%s - %s", String.join(" / ", command.getNames()), command.getShortDesc()));
logDirect("");
command.getLongDesc().forEach(this::logDirect);
logDirect("");
ITextComponent returnComponent = new TextComponentString("Click to return to the help menu");
returnComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + label));
logDirect(returnComponent);
}
}
use of baritone.api.command.ICommand in project Spark-Client by Spark-Client-Development.
the class CommandManager method from.
private ExecutionWrapper from(Tuple<String, List<ICommandArgument>> expanded) {
String label = expanded.getFirst();
ArgConsumer args = new ArgConsumer(this, expanded.getSecond());
ICommand command = this.getCommand(label);
return command == null ? null : new ExecutionWrapper(command, label, args);
}
use of baritone.api.command.ICommand in project baritone by cabaletta.
the class CommandManager method from.
private ExecutionWrapper from(Tuple<String, List<ICommandArgument>> expanded) {
String label = expanded.getFirst();
ArgConsumer args = new ArgConsumer(this, expanded.getSecond());
ICommand command = this.getCommand(label);
return command == null ? null : new ExecutionWrapper(command, label, args);
}
Aggregations