From 2a92a02dd90b31ad91d2c0a8b4d436cb9aca973b Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Wed, 5 Apr 2023 16:52:35 +0700 Subject: [PATCH] actually sort commands in help --- .../chayapak/chomens_bot/commands/HelpCommand.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 ba5591e..25d87a7 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 @@ -8,6 +8,7 @@ import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class HelpCommand implements Command { @@ -71,13 +72,20 @@ public class HelpCommand implements Command { context.sendOutput(component); } - public List getCommandListByTrustLevel (int trustLevel) { + public List getCommandListByTrustLevel(int trustLevel) { final List list = new ArrayList<>(); - for (Command command : bot.commandHandler().commands()) { - final String name = command.name(); + List commandNames = new ArrayList<>(); + for (Command command : bot.commandHandler().commands()) { if (command.trustLevel() != trustLevel) continue; + + commandNames.add(command.name()); + } + + Collections.sort(commandNames); + + for (String name : commandNames) { list.add(Component.text(name).color(getColorByTrustLevel(trustLevel))); }