diff --git a/build-number.txt b/build-number.txt index bf6edd4e..65c67905 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1634 \ No newline at end of file +1636 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java b/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java index 1404734c..e969d095 100644 --- a/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java +++ b/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java @@ -1,8 +1,19 @@ package me.chayapak1.chomens_bot.command; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; + public enum TrustLevel { - PUBLIC, - TRUSTED, - ADMIN, - OWNER + PUBLIC(0, Component.text("Public").color(NamedTextColor.GREEN)), + TRUSTED(1, Component.text("Trusted").color(NamedTextColor.RED)), + ADMIN(2, Component.text("Admin").color(NamedTextColor.DARK_RED)), + OWNER(3, Component.text("Owner").color(NamedTextColor.LIGHT_PURPLE)); + + public final int level; + public final Component component; + + TrustLevel (int level, Component component) { + this.level = level; + this.component = component; + } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java index 12eaa36c..c7ec408e 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java @@ -12,6 +12,7 @@ import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; import java.util.ArrayList; import java.util.Arrays; @@ -54,16 +55,20 @@ public class HelpCommand extends Command { list.addAll(getCommandListByTrustLevel(TrustLevel.ADMIN)); list.addAll(getCommandListByTrustLevel(TrustLevel.OWNER)); + final Component trustLevels = Component.join( + JoinConfiguration.spaces(), + Arrays.stream(TrustLevel.values()) + .map(level -> level.component) + .toList() + ); + return Component.empty() .append(Component.text("Commands ").color(NamedTextColor.GRAY)) .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) .append(Component.text(list.size()).color(NamedTextColor.GREEN)) .append(Component.text(") ").color(NamedTextColor.DARK_GRAY)) .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text("Public ").color(NamedTextColor.GREEN)) - .append(Component.text("Trusted ").color(NamedTextColor.RED)) - .append(Component.text("Admin ").color(NamedTextColor.DARK_RED)) - .append(Component.text("Owner").color(NamedTextColor.LIGHT_PURPLE)) + .append(Component.translatable("%s", trustLevels)) .append(Component.text(") - ").color(NamedTextColor.DARK_GRAY)) .append(Component.join(JoinConfiguration.separator(Component.space()), list)); } @@ -101,13 +106,8 @@ public class HelpCommand extends Command { return list; } - public NamedTextColor getColorByTrustLevel (TrustLevel trustLevel) { - return switch (trustLevel) { - case PUBLIC -> NamedTextColor.GREEN; - case TRUSTED -> NamedTextColor.RED; - case ADMIN -> NamedTextColor.DARK_RED; - case OWNER -> NamedTextColor.LIGHT_PURPLE; - }; + public TextColor getColorByTrustLevel (TrustLevel trustLevel) { + return trustLevel.component.color(); } public Component sendUsages (CommandContext context, String commandName) throws CommandException { @@ -135,7 +135,11 @@ public class HelpCommand extends Command { usages.add( Component.empty() .append(Component.text("Trust level: ").color(NamedTextColor.GREEN)) - .append(Component.text(command.trustLevel.name()).color(NamedTextColor.YELLOW)) + .append( + command.trustLevel.component + .append(Component.text(" - ")) + .append(Component.text(command.trustLevel.level)) + ) ); for (String usage : command.usages) { diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ValidateCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ValidateCommand.java index 75fd3014..09f53e0a 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ValidateCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ValidateCommand.java @@ -18,16 +18,23 @@ public class ValidateCommand extends Command { @Override public Component execute(CommandContext context) throws CommandException { + // Trusted - 1 + // Admin - 2 + // ....... + final Component trustLevelComponent = context.trustLevel.component + .append(Component.text(" - ")) + .append(Component.text(context.trustLevel.level)); + if (context instanceof DiscordCommandContext) return Component .translatable("You are trusted! (%s)") - .arguments(Component.text(context.trustLevel.name())) + .arguments(trustLevelComponent) .color(NamedTextColor.GREEN); else if (context instanceof ConsoleCommandContext) return Component .text("You are the console! You have no trust level") .color(NamedTextColor.GREEN); else return Component .translatable("Valid hash (%s)") - .arguments(Component.text(context.trustLevel.name())) + .arguments(trustLevelComponent) .color(NamedTextColor.GREEN); } }