diff --git a/Bungee/src/main/java/net/frankheijden/serverutils/bungee/commands/CommandServerUtils.java b/Bungee/src/main/java/net/frankheijden/serverutils/bungee/commands/CommandServerUtils.java index cf5d132..a076a5e 100644 --- a/Bungee/src/main/java/net/frankheijden/serverutils/bungee/commands/CommandServerUtils.java +++ b/Bungee/src/main/java/net/frankheijden/serverutils/bungee/commands/CommandServerUtils.java @@ -3,6 +3,8 @@ package net.frankheijden.serverutils.bungee.commands; import static net.frankheijden.serverutils.common.config.Messenger.sendMessage; import co.aikar.commands.BaseCommand; +import co.aikar.commands.RegisteredCommand; +import co.aikar.commands.RootCommand; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -61,16 +63,21 @@ public class CommandServerUtils extends BaseCommand { FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format")) .orderedKeys("%command%", "%subcommand%", "%help%"); - plugin.getCommandManager().getRegisteredRootCommands().stream() - .filter(c -> !ALIASES.contains(c.getCommandName().toLowerCase())) - .forEach(rootCommand -> { - builder.add(rootCommand.getCommandName(), "", rootCommand.getDescription()); - rootCommand.getSubCommands().forEach((str, cmd) -> { - if (cmd.getPrefSubCommand().isEmpty()) return; - builder.add(rootCommand.getCommandName(), " " + cmd.getPrefSubCommand(), cmd.getHelpText()); - }); - }); + Set rootCommands = new HashSet<>(); + for (RootCommand root : plugin.getCommandManager().getRegisteredRootCommands()) { + String rootName = root.getDefCommand().getName(); + if (!rootCommands.add(rootName)) continue; + builder.add(rootName, "", root.getDescription()); + + Set subCommands = new HashSet<>(); + for (RegisteredCommand sub : root.getSubCommands().values()) { + String name = sub.getPrefSubCommand().toLowerCase(); + if (name.isEmpty()) continue; + if (!subCommands.add(name)) continue; + builder.add(rootName, " " + name, sub.getHelpText()); + } + } builder.sendTo(sender); Messenger.sendMessage(sender, "serverutils.help.footer"); } diff --git a/Velocity/src/main/java/net/frankheijden/serverutils/velocity/commands/CommandServerUtils.java b/Velocity/src/main/java/net/frankheijden/serverutils/velocity/commands/CommandServerUtils.java index d44446c..fc6084e 100644 --- a/Velocity/src/main/java/net/frankheijden/serverutils/velocity/commands/CommandServerUtils.java +++ b/Velocity/src/main/java/net/frankheijden/serverutils/velocity/commands/CommandServerUtils.java @@ -1,6 +1,8 @@ package net.frankheijden.serverutils.velocity.commands; import co.aikar.commands.BaseCommand; +import co.aikar.commands.RegisteredCommand; +import co.aikar.commands.RootCommand; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -64,16 +66,21 @@ public class CommandServerUtils extends BaseCommand { FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format")) .orderedKeys("%command%", "%subcommand%", "%help%"); - plugin.getCommandManager().getRegisteredRootCommands().stream() - .filter(c -> !ALIASES.contains(c.getCommandName().toLowerCase())) - .forEach(rootCommand -> { - builder.add(rootCommand.getCommandName(), "", rootCommand.getDescription()); - rootCommand.getSubCommands().forEach((str, cmd) -> { - if (cmd.getPrefSubCommand().isEmpty()) return; - builder.add(rootCommand.getCommandName(), " " + cmd.getPrefSubCommand(), cmd.getHelpText()); - }); - }); + Set rootCommands = new HashSet<>(); + for (RootCommand root : plugin.getCommandManager().getRegisteredRootCommands()) { + String rootName = root.getDefCommand().getName(); + if (!rootCommands.add(rootName)) continue; + builder.add(rootName, "", root.getDescription()); + + Set subCommands = new HashSet<>(); + for (RegisteredCommand sub : root.getSubCommands().values()) { + String name = sub.getPrefSubCommand().toLowerCase(); + if (name.isEmpty()) continue; + if (!subCommands.add(name)) continue; + builder.add(rootName, " " + name, sub.getHelpText()); + } + } builder.sendTo(sender); Messenger.sendMessage(sender, "serverutils.help.footer"); }