Gradle isn't serching the right repository for plugins

I have this plugin and I’m trying to add it to my multi module gradle project. I want to add the plugin into one of my conventions, however I get this error:

> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':api:classpath'.
      > Could not find io.papermc.paperweight:paperweight-userdev:1.3.8.
        Searched in the following locations:
        If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
        Required by:
            project :api > project :build-logic

I have the error for my other repository I have added, and no errors for the repository that the plugin is actually in. I’ve defined it something like this

dependencies {

repositories {

(Using kotling DSL, so if possible answers in kotlin would be nice)

It looks like you’re trying to depend on a plugin using the repositories and dependencies for the project code you’re building, not the buildscript. Dependencies of the build itself (plugins) are different than dependencies of the project being built.

For examples (including Kotlin DSL) of how to properly do this, look at Custom Plugin Repositories and Applying Plugins with Buildscript Block in the Using Plugins docs.

Nah, I think what he showed is the build script of build-logic where it is correct to define the repository as production repository.

Am I right, that the plugin also is building fine, but then fails when it tries to apply it?

Repository configuration does not propagate from producer builds to consumer builds.
You defined the papermc repository for building the plugin and the building probably works, but that is completely independent for various very good reasons from the repositories when using the plugin.
Add the papermc repository in the pluginManagement { repositories { ... } } block of the settings script of the build that applies the plugin so that the build can find all the dependencies the plugin is using.