@Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        // It is assumed that entering the menu command without parameters is an
        // attempt to get information about it. So let's give it to them.
        if (args.length == 0) {
            for (Map.Entry<String, IMenuCommand> entry : subCommands.entrySet()) {
                String name = entry.getKey();
                IMenuCommand menuCommand = entry.getValue();
                String permission = menuCommand.getPermission();
                if (permission != null && sender.hasPermission(permission)) {
                    sender.sendMessage(plugin.translate(sender, "menu-" + name + "-usage", menuCommand.getUsage()));
                }
            }
            return true;
        }

        String subCommandName = args[0].toLowerCase();
        IMenuCommand menuCommand = subCommands.get(subCommandName);
        if (menuCommand == null) {
            return false; // They mistyped or entered an invalid subcommand
        }
        // Handle the permissions check
        String permission = menuCommand.getPermission();
        if (permission != null && !sender.hasPermission(permission)) {
            sender.sendMessage(plugin.translate(sender, "command-no-perms", "You do not have permission to use this command"));
            return true;
        }
        // Remove the sub-command from the args list and pass along the rest
        if (!menuCommand.onCommand(sender, command, label, Arrays.copyOfRange(args, 1, args.length))) {
            // A sub-command returning false should display the usage information for that sub-command
            sender.sendMessage(plugin.translate(sender, "menu-" + subCommandName + "-usage", menuCommand.getUsage()));
        }
        return true;
    }