plugins {
    id 'java'
    id 'com.gradleup.shadow' version '9.6.1'
    id 'xyz.jpenilla.run-paper' version '3.0.2'
}

group = 'eu.mhsl.minecraft'
version = '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven {
        name = "papermc-repo"
        url = "https://repo.papermc.io/repository/maven-public/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
    maven {
        url = "https://repo.aikar.co/content/groups/aikar/"
    }
}

dependencies {
    compileOnly "io.papermc.paper:paper-api:26.2.build.65-beta"
    implementation "co.aikar:taskchain-bukkit:3.7.2"
}

java {
    toolchain.languageVersion = JavaLanguageVersion.of(25)
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset = 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}

// Zielverzeichnis über testServerPluginsDir in gradle.properties oder -PtestServerPluginsDir=... setzen
tasks.register('copyJarToTestServer', Exec) {
    def pluginsDir = providers.gradleProperty('testServerPluginsDir').getOrNull()
    onlyIf { pluginsDir != null }
    commandLine 'cp', "build/libs/PixelBlocks-${version}-all.jar", "${pluginsDir}/PixelBlocks-${version}-all.jar"
}

shadowJar {
    relocate 'co.aikar.taskchain', 'eu.mhsl.minecraft.pixelblocks.taskchain'
}

runServer {
    minecraftVersion '26.2'
    systemProperty 'com.mojang.eula.agree', 'true'
}

jar.dependsOn shadowJar
copyJarToTestServer.dependsOn jar
