From c26c1603ac66e3bb192144aed459058bd91f7354 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Fri, 28 Apr 2023 18:13:18 +0700 Subject: [PATCH] finally add usage to help's hoverevent piece of shit --- .../chomens_bot/commands/HelpCommand.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java index 7e495c3..cbcba8c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java @@ -5,6 +5,7 @@ import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; +import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; import java.util.ArrayList; @@ -40,8 +41,11 @@ public class HelpCommand implements Command { private Bot bot; + private CommandContext context; + public Component execute(CommandContext context, String[] args, String[] fullArgs) { this.bot = context.bot(); + this.context = context; if (args.length == 0) { return sendCommandList(); } else { @@ -83,7 +87,16 @@ public class HelpCommand implements Command { Collections.sort(commandNames); for (String name : commandNames) { - list.add(Component.text(name).color(getColorByTrustLevel(trustLevel))); + list.add( + Component + .text(name) + .color(getColorByTrustLevel(trustLevel)) + .hoverEvent( + HoverEvent.showText( + sendUsages(context, new String[] { name }) + ) + ) + ); } return list;