List all subcommands if debug section is unknown
This commit is contained in:
parent
a847deac16
commit
8a7c8c36f2
@ -26,20 +26,23 @@ public class DebugCommand implements ExecutableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
if (arguments.isEmpty()) {
|
DebugSection debugSection = getDebugSection(arguments);
|
||||||
|
if (debugSection == null) {
|
||||||
sender.sendMessage("Available sections:");
|
sender.sendMessage("Available sections:");
|
||||||
getSections().values()
|
getSections().values()
|
||||||
.forEach(e -> sender.sendMessage("- " + e.getName() + ": " + e.getDescription()));
|
.forEach(e -> sender.sendMessage("- " + e.getName() + ": " + e.getDescription()));
|
||||||
} else {
|
} else {
|
||||||
DebugSection debugSection = getSections().get(arguments.get(0).toLowerCase());
|
debugSection.execute(sender, arguments.subList(1, arguments.size()));
|
||||||
if (debugSection == null) {
|
|
||||||
sender.sendMessage("Unknown subcommand");
|
|
||||||
} else {
|
|
||||||
debugSection.execute(sender, arguments.subList(1, arguments.size()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DebugSection getDebugSection(List<String> arguments) {
|
||||||
|
if (arguments.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getSections().get(arguments.get(0).toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
// Lazy getter
|
// Lazy getter
|
||||||
private Map<String, DebugSection> getSections() {
|
private Map<String, DebugSection> getSections() {
|
||||||
if (sections == null) {
|
if (sections == null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user