forked from ChomeNS/chomens-bot-java
extra info on the Expected %s
This commit is contained in:
parent
eb8676d969
commit
1120cbbc09
1 changed files with 14 additions and 2 deletions
|
@ -3,10 +3,14 @@ package land.chipmunk.chayapak.chomens_bot.command;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.Style;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CommandContext {
|
public class CommandContext {
|
||||||
|
public static final Component UNKNOWN_ARGUMENT_COMPONENT = Component.text("???").style(Style.style(TextDecoration.UNDERLINED));
|
||||||
|
|
||||||
public final Bot bot;
|
public final Bot bot;
|
||||||
|
|
||||||
public final String prefix;
|
public final String prefix;
|
||||||
|
@ -38,8 +42,16 @@ public class CommandContext {
|
||||||
if (required) {
|
if (required) {
|
||||||
throw new CommandException(
|
throw new CommandException(
|
||||||
Component.translatable(
|
Component.translatable(
|
||||||
"Expected %s",
|
"Expected %s at position %s (%s %s)",
|
||||||
Component.text(type)
|
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 {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue