From d20f7532bfbf60d8b18b6f392f8163894b613db2 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:45:21 +0700 Subject: [PATCH] fix: only show `[click for usages]` when in game --- build-number.txt | 2 +- .../chomens_bot/command/CommandContext.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build-number.txt b/build-number.txt index 8fad7c29..c6778f88 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1354 \ No newline at end of file +1355 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java b/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java index 76398416..d14bab52 100644 --- a/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java +++ b/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java @@ -49,7 +49,7 @@ public class CommandContext { if (required) { throw new CommandException( Component.translatable( - "Expected %s at position %s (%s %s) [%s]", + "Expected %s at position %s (%s %s)%s", Component.text(type), Component.text(argsPosition), Component.text(prefix + userInputCommandName), @@ -59,9 +59,18 @@ public class CommandContext { .text(String.join(" ", args)) .append(Component.space()) .append(UNKNOWN_ARGUMENT_COMPONENT), - Component - .text("click for usages") - .clickEvent(ClickEvent.suggestCommand(prefix + "help " + this.commandName)) + inGame ? + Component + .space() + .append( + Component.translatable("[%s]") + .arguments( + Component + .text("click for usages") + .clickEvent(ClickEvent.suggestCommand(prefix + "help " + this.commandName)) + ) + ) : + Component.empty() ) ); } else {