diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java index 9d67da39..c910cb92 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java @@ -26,20 +26,23 @@ public class DebugCommand implements ExecutableCommand { @Override public void executeCommand(CommandSender sender, List arguments) { - if (arguments.isEmpty()) { + DebugSection debugSection = getDebugSection(arguments); + if (debugSection == null) { sender.sendMessage("Available sections:"); getSections().values() .forEach(e -> sender.sendMessage("- " + e.getName() + ": " + e.getDescription())); } else { - DebugSection debugSection = getSections().get(arguments.get(0).toLowerCase()); - if (debugSection == null) { - sender.sendMessage("Unknown subcommand"); - } else { - debugSection.execute(sender, arguments.subList(1, arguments.size())); - } + debugSection.execute(sender, arguments.subList(1, arguments.size())); } } + private DebugSection getDebugSection(List arguments) { + if (arguments.isEmpty()) { + return null; + } + return getSections().get(arguments.get(0).toLowerCase()); + } + // Lazy getter private Map getSections() { if (sections == null) {