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
|
|
@ -3,6 +3,8 @@ package net.frankheijden.serverutils.bungee.commands;
|
||||||
import static net.frankheijden.serverutils.common.config.Messenger.sendMessage;
|
import static net.frankheijden.serverutils.common.config.Messenger.sendMessage;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
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.CommandAlias;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import co.aikar.commands.annotation.CommandCompletion;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
|
|
@ -61,16 +63,21 @@ public class CommandServerUtils extends BaseCommand {
|
||||||
|
|
||||||
FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format"))
|
FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format"))
|
||||||
.orderedKeys("%command%", "%subcommand%", "%help%");
|
.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) -> {
|
Set<String> rootCommands = new HashSet<>();
|
||||||
if (cmd.getPrefSubCommand().isEmpty()) return;
|
for (RootCommand root : plugin.getCommandManager().getRegisteredRootCommands()) {
|
||||||
builder.add(rootCommand.getCommandName(), " " + cmd.getPrefSubCommand(), cmd.getHelpText());
|
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);
|
builder.sendTo(sender);
|
||||||
Messenger.sendMessage(sender, "serverutils.help.footer");
|
Messenger.sendMessage(sender, "serverutils.help.footer");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package net.frankheijden.serverutils.velocity.commands;
|
package net.frankheijden.serverutils.velocity.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
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.CommandAlias;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import co.aikar.commands.annotation.CommandCompletion;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
|
|
@ -64,16 +66,21 @@ public class CommandServerUtils extends BaseCommand {
|
||||||
|
|
||||||
FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format"))
|
FormatBuilder builder = FormatBuilder.create(Messenger.getMessage("serverutils.help.format"))
|
||||||
.orderedKeys("%command%", "%subcommand%", "%help%");
|
.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) -> {
|
Set<String> rootCommands = new HashSet<>();
|
||||||
if (cmd.getPrefSubCommand().isEmpty()) return;
|
for (RootCommand root : plugin.getCommandManager().getRegisteredRootCommands()) {
|
||||||
builder.add(rootCommand.getCommandName(), " " + cmd.getPrefSubCommand(), cmd.getHelpText());
|
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);
|
builder.sendTo(sender);
|
||||||
Messenger.sendMessage(sender, "serverutils.help.footer");
|
Messenger.sendMessage(sender, "serverutils.help.footer");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue