private static String buildPermissionNode(CommandNodeWithParent node) {
        StringBuilder builder = new StringBuilder();

        while (node != null) {
            if (node.node instanceof LiteralCommandNode) {
                if (builder.length() != 0) {
                    builder.insert(0, '.');
                }

                String name = node.node.getName().toLowerCase(Locale.ROOT);
                builder.insert(0, name);
            }

            node = node.parent;
        }

        if (builder.length() == 0) {
            return null;
        }

        builder.insert(0, "command.");
        return builder.toString();
    }
Inject permission requirements into the commands in the given dispatcher.

@param plugin the plugin
@param dispatcher the command dispatcher
forge/src/main/java/me/lucko/luckperms/forge/util/BrigadierInjector.java