actually sort commands in help

This commit is contained in:
Chayapak 2023-04-05 16:52:35 +07:00
parent 5958da7b86
commit 2a92a02dd9

View file

@ -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 {
@ -74,10 +75,17 @@ public class HelpCommand implements Command {
public List<Component> getCommandListByTrustLevel(int trustLevel) {
final List<Component> list = new ArrayList<>();
for (Command command : bot.commandHandler().commands()) {
final String name = command.name();
List<String> 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)));
}