[JAVA] [Bukkit, Spigot, Paper] plugin.yml also writes build.gradle.kts

plugin-yml https://github.com/Minecrell/plugin-yml

Use this. There is also build.gralde in the example, so if you like that, please try it.

By the way, the kotlin-dsl example is wrong. I can't set commands or permissions. " test " to register ("test ") "testplugin. * " to register ("testplugin. * ") You can change it to. Details are explained at the bottom of this article.

Gradle Only build.gradle.kts is available. ~~ Can someone write an example of build.gradle ~~ Select the one that suits you and press ▶. ** Please edit the part that is @TODO **

build.gradle (Groovy) waiting.

build.gradle.kts (Kotlin)

If you have build.gradle, rename the file to build.gradle.kts. The grammar is a little different, so I think you'll get an error if you don't fix it.

Example

Spigot 1.15.2 + Java

build.gradle.kts


plugins {
    java
    id("net.minecrell.plugin-yml.bukkit") version "0.3.0"
}

group = "" // @TODO edit here
version = "1.0" // @TODO edit here

repositories {
    mavenCentral()
    maven {
        url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
    }
    maven {
        url = uri("https://oss.sonatype.org/content/repositories/snapshots")
    }
}

dependencies {
    implementation("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
}

bukkit {
    //I will explain in detail
}

val jar by tasks.getting(Jar::class) {
    from(configurations.compileOnly.get().map {
        if (it.isDirectory) it else zipTree(it)
    })
}
Paper 1.15.2 + Kotlin

build.gradle.kts


plugins {
    kotlin("jvm") version "1.3.72"
    id("net.minecrell.plugin-yml.bukkit") version "0.3.0"
}

group = "" // @TODO edit here
version = "1.0" // @TODO edit here

repositories {
    mavenCentral()
    maven {
        url = uri("https://papermc.io/repo/repository/maven-public/")
    }
}

dependencies {
    implementation("com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT")
    compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}

bukkit {
    //I will explain in detail
}

tasks {
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
}

val jar by tasks.getting(Jar::class) {
    from(configurations.compileOnly.get().map {
        if (it.isDirectory) it else zipTree(it)
    })
}

write bukkit {}

minimum
bukkit {
    main = "" // @Path to a class that inherits TODO JavaPlugin
    apiVersion = "1.15"
        // 1.13.1 for X.13
        // 1.14.1 for X.14
        // 1.15.1 for X.15
}

But I think it's better to write about ʻauthor`.

Example guy

I modified the one on GitHub appropriately. If you can make it correspond, you can write it perfectly.

bukkit {
    main = "com.example.testplugin.TestPlugin"
    apiVersion = "1.13"
    load = BukkitPluginDescription.PluginLoadOrder.STARTUP // or POSTWORLD 
    authors = listOf("Notch", "Notch2")
    depend = listOf("WorldEdit")
    softDepend = listOf("Essentials")
    loadBefore = listOf("BrokenPlugin")
    prefix = "TEST"
    defaultPermission = BukkitPluginDescription.Permission.Default.OP // TRUE, FALSE, OP or NOT_OP
    
    commands {
        register("test") {
            description = "This is a test command!"
            aliases = listOf("t")
            permission = "testplugin.test"
            usage = "Just run the command!"
            // permissionMessage = "You may not test this command!" 
        }
        // ...
    }
    
    permissions {
        register("testplugin.*") {
            children = listOf("testplugin.test")
        }
        register("testplugin.test") {
            description = "Allows you to run the test command"
            default = BukkitPluginDescription.Permission.Default.OP // TRUE, FALSE, OP or NOT_OP
        }
        // ...
    }
}

Finally

It's great to have less space to edit. It supports not only Bukkit but also BungeeCord and Nukkit. It will be easier to respond to project updates (version upgrades, etc.), so please use it. Please do not hesitate to make an edit request, as some parts may be lacking in explanation.

Recommended Posts

[Bukkit, Spigot, Paper] plugin.yml also writes build.gradle.kts