un-poz some Command stuff
This commit is contained in:
parent
1440e81ea4
commit
29d8ab43f2
@ -37,25 +37,21 @@ public abstract class Command implements Helper {
|
||||
/**
|
||||
* The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
public final List<String> names;
|
||||
protected final List<String> names;
|
||||
|
||||
/**
|
||||
* Creates a new Baritone control command.
|
||||
*
|
||||
* @param names The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
protected Command(IBaritone baritone, List<String> names) {
|
||||
this.names = names.stream()
|
||||
protected Command(IBaritone baritone, String... names) {
|
||||
this.names = Collections.unmodifiableList(Stream.of(names)
|
||||
.map(s -> s.toLowerCase(Locale.US))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toList()));
|
||||
this.baritone = baritone;
|
||||
this.ctx = baritone.getPlayerContext();
|
||||
}
|
||||
|
||||
protected Command(IBaritone baritone, String name) {
|
||||
this(baritone, Collections.singletonList(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this command is executed.
|
||||
*/
|
||||
@ -83,4 +79,8 @@ public abstract class Command implements Helper {
|
||||
public boolean hiddenFromHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final List<String> getNames() {
|
||||
return this.names;
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class TabCompleteHelper {
|
||||
*/
|
||||
public TabCompleteHelper addCommands(ICommandManager manager) {
|
||||
return append(manager.getRegistry().descendingStream()
|
||||
.flatMap(command -> command.names.stream())
|
||||
.flatMap(command -> command.getNames().stream())
|
||||
.distinct()
|
||||
);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import java.util.stream.Stream;
|
||||
public class AxisCommand extends Command {
|
||||
|
||||
public AxisCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("axis", "highway"));
|
||||
super(baritone, "axis", "highway");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ import java.util.stream.Stream;
|
||||
public class CancelCommand extends Command {
|
||||
|
||||
public CancelCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("cancel", "stop"));
|
||||
super(baritone, "cancel", "stop");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +31,7 @@ public class CommandAlias extends Command {
|
||||
public final String target;
|
||||
|
||||
public CommandAlias(IBaritone baritone, List<String> names, String shortDesc, String target) {
|
||||
super(baritone, names);
|
||||
super(baritone, names.toArray(new String[0]));
|
||||
this.shortDesc = shortDesc;
|
||||
this.target = target;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREF
|
||||
public class HelpCommand extends Command {
|
||||
|
||||
public HelpCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("help", "?"));
|
||||
super(baritone, "help", "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,8 +55,8 @@ public class HelpCommand extends Command {
|
||||
),
|
||||
() -> logDirect("All Baritone commands (clickable):"),
|
||||
command -> {
|
||||
String names = String.join("/", command.names);
|
||||
String name = command.names.get(0);
|
||||
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);
|
||||
@ -66,7 +66,7 @@ public class HelpCommand extends Command {
|
||||
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.names.get(0));
|
||||
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);
|
||||
@ -83,7 +83,7 @@ public class HelpCommand extends Command {
|
||||
if (command == null) {
|
||||
throw new CommandNotFoundException(commandName);
|
||||
}
|
||||
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
||||
logDirect(String.format("%s - %s", String.join(" / ", command.getNames()), command.getShortDesc()));
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
|
@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
||||
public class PathCommand extends Command {
|
||||
|
||||
public PathCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("path", "goto"));
|
||||
super(baritone, "path", "goto");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ import java.util.stream.Stream;
|
||||
public class RepackCommand extends Command {
|
||||
|
||||
public RepackCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("repack", "rescan"));
|
||||
super(baritone, "repack", "rescan");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class SelCommand extends Command {
|
||||
private BetterBlockPos pos1 = null;
|
||||
|
||||
public SelCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("sel", "selection", "s"));
|
||||
super(baritone, "sel", "selection", "s");
|
||||
baritone.getGameEventHandler().registerEventListener(new AbstractGameEventListener() {
|
||||
@Override
|
||||
public void onRenderPass(RenderEvent event) {
|
||||
|
@ -46,7 +46,7 @@ import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREF
|
||||
public class SetCommand extends Command {
|
||||
|
||||
public SetCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("set", "setting", "settings"));
|
||||
super(baritone, "set", "setting", "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ import java.util.stream.Stream;
|
||||
public class ThisWayCommand extends Command {
|
||||
|
||||
public ThisWayCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("thisway", "forward"));
|
||||
super(baritone, "thisway", "forward");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +48,7 @@ import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREF
|
||||
public class WaypointsCommand extends Command {
|
||||
|
||||
public WaypointsCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("waypoints", "waypoint", "wp"));
|
||||
super(baritone, "waypoints", "waypoint", "wp");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,7 +64,7 @@ public class CommandManager implements ICommandManager {
|
||||
@Override
|
||||
public Command getCommand(String name) {
|
||||
for (Command command : this.registry.entries) {
|
||||
if (command.names.contains(name.toLowerCase(Locale.US))) {
|
||||
if (command.getNames().contains(name.toLowerCase(Locale.US))) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user