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

2 minute read

plugin-yml

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

I will use this. There is also build.gralde in the example, so if you like it, 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. For details, see the bottom of this article.

Gradle

Only build.gradle.kts is prepared. ~~ Build.gradle example, can anyone write me ~~ Select the one that suits you and press ▶. **Please edit the part where @TODO is **

build.gradle (Groovy)

waiting.

build.gradle.kts (Kotlin)

If you have build.gradle, change the file name to build.gradle.kts. The syntax is a little different, so if you don’t fix it, you’ll get an error.

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 the class that inherits @TODO JavaPlugin
    apiVersion = "1.15"
        // 1.13.X for 1.13
        // 1.14.X for 1.14
        // 1.15.X for 1.15
}

But I think you should write about author.

Example guy

I modified GitHub’s one appropriately. If you can correspond, you can write 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 that there are less places to edit. Not only Bukkit but also BungeeCord and Nukkit are supported. Supporting project updates (version upgrades, etc.) will be easier, so please use it. Don’t hesitate to make edit requests, as it may not be fully explained.