From 1120cbbc094b8684bfb5d003d3cfb5abe6b3bd4f Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 24 Sep 2023 17:06:12 +0700 Subject: [PATCH] extra info on the Expected %s --- .../chomens_bot/command/CommandContext.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java index 2d58550..79bce6d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java @@ -3,10 +3,14 @@ package land.chipmunk.chayapak.chomens_bot.command; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.Style; +import net.kyori.adventure.text.format.TextDecoration; import java.util.Arrays; public class CommandContext { + public static final Component UNKNOWN_ARGUMENT_COMPONENT = Component.text("???").style(Style.style(TextDecoration.UNDERLINED)); + public final Bot bot; public final String prefix; @@ -38,8 +42,16 @@ public class CommandContext { if (required) { throw new CommandException( Component.translatable( - "Expected %s", - Component.text(type) + "Expected %s at position %s (%s %s)", + Component.text(type), + Component.text(argsPosition), + Component.text(prefix + commandName), + argsPosition == 0 ? + UNKNOWN_ARGUMENT_COMPONENT : + Component + .text(String.join(" ", args)) + .append(Component.space()) + .append(UNKNOWN_ARGUMENT_COMPONENT) ) ); } else {