Yay code duplication for this PR, next PR implements cloud smh
This commit is contained in:
parent
f10407b5ea
commit
02bee8c839
2 changed files with 32 additions and 18 deletions
|
|
@ -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<String> 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<String> 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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue