Search in sources :

Example 1 with Command

use of org.bleachhack.command.Command in project BleachHack by BleachDrinker420.

the class CmdHelp method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    String cmd = args.length == 0 ? "" : args[0];
    if (cmd.isEmpty()) {
        BleachLogger.info("Commands:");
    } else {
        BleachLogger.info("Syntax for " + getPrefix() + cmd.toLowerCase(Locale.ENGLISH) + ":");
    }
    for (Command c : CommandManager.getCommands()) {
        if (!cmd.isEmpty() && Stream.of(c.getAliases()).noneMatch(cmd::equalsIgnoreCase))
            continue;
        MutableText text = new LiteralText(getPrefix() + c.getAliases()[0] + ": \u00a7f" + c.getDescription()).styled(s -> s.withColor(BleachLogger.INFO_COLOR));
        BleachLogger.noPrefix(text.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c.getHelpTooltip()))));
    }
}
Also used : MutableText(net.minecraft.text.MutableText) CommandCategory(org.bleachhack.command.CommandCategory) CommandManager(org.bleachhack.command.CommandManager) LiteralText(net.minecraft.text.LiteralText) Stream(java.util.stream.Stream) Locale(java.util.Locale) Command(org.bleachhack.command.Command) BleachLogger(org.bleachhack.util.BleachLogger) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) HoverEvent(net.minecraft.text.HoverEvent) Command(org.bleachhack.command.Command) LiteralText(net.minecraft.text.LiteralText)

Aggregations

Locale (java.util.Locale)1 Stream (java.util.stream.Stream)1 HoverEvent (net.minecraft.text.HoverEvent)1 LiteralText (net.minecraft.text.LiteralText)1 MutableText (net.minecraft.text.MutableText)1 Command (org.bleachhack.command.Command)1 CommandCategory (org.bleachhack.command.CommandCategory)1 CommandManager (org.bleachhack.command.CommandManager)1 BleachLogger (org.bleachhack.util.BleachLogger)1