diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java index c6d18fd..da3567a 100644 --- a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java @@ -11,6 +11,7 @@ package com.imaginarycode.minecraft.redisbungee.commands; import co.aikar.commands.CommandIssuer; +import co.aikar.commands.RegisteredCommand; import co.aikar.commands.annotation.*; import com.google.common.primitives.Ints; import com.imaginarycode.minecraft.redisbungee.Constants; @@ -26,12 +27,12 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; @CommandAlias("rb|redisbungee") @CommandPermission("redisbungee.command.use") +@Description("Main command") public class CommandRedisBungee extends AdventureBaseCommand { private final RedisBungeePlugin plugin; @@ -66,19 +67,29 @@ public class CommandRedisBungee extends AdventureBaseCommand { } // ......: ...... @HelpCommand + @Description("shows the help page") public void help(CommandIssuer issuer) { - final String message = """ - ======================================== - /rb info: shows info of this version. - /rb help: shows this page. - /rb clean: cleans up the uuid cache - WARNING... command above could cause performance issues - /rb show: shows list of proxies with player count - ======================================== - run /rb help for more commands"""; - sendMessage(issuer, MiniMessage.miniMessage().deserialize(message)); + final String barFormat = "========================================"; + final String commandFormat = "/rb : "; + + TextComponent.Builder message = Component.text(); + message.append(MiniMessage.miniMessage().deserialize(barFormat)); + + getSubCommands().forEach((subCommand, registeredCommand) -> { + String[] split = registeredCommand.getCommand().split(" "); + if (split.length > 1 && subCommand.equalsIgnoreCase(split[1])) { + message.appendNewline().append(MiniMessage.miniMessage().deserialize(commandFormat, Placeholder.component("sub-command", Component.text(subCommand)), + Placeholder.component("description", MiniMessage.miniMessage().deserialize(registeredCommand.getHelpText())) + )); + } + }); + + message.appendNewline().append(MiniMessage.miniMessage().deserialize(barFormat)); + + sendMessage(issuer, message.build()); } @Subcommand("clean") + @Description("cleans up the uuid cache WARNING... command above could cause performance issues") @Private public void cleanUp(CommandIssuer issuer) { if (StopperUUIDCleanupTask.isRunning) { @@ -98,6 +109,7 @@ public class CommandRedisBungee extends AdventureBaseCommand { } @Subcommand("show") + @Description("Shows proxies in this network") public void showProxies(CommandIssuer issuer, String[] args) { final String closer = "========================================"; final String pageTop = "Page: / Network ID: Proxies online: ";