change to kotlin (it works unlike another private project)

This commit is contained in:
Jannik Reimers 2024-06-07 08:23:28 +02:00
parent 436e9f46ce
commit 8f8bb71c1b
7 changed files with 114 additions and 60 deletions

View File

@ -1,49 +0,0 @@
plugins {
id 'java'
}
group = 'moe.jansel'
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/"
}
}
dependencies {
compileOnly "io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT"
}
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('paper-plugin.yml') {
expand props
}
}

60
build.gradle.kts Normal file
View File

@ -0,0 +1,60 @@
plugins {
kotlin("jvm") version "2.0.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.kyori.blossom") version "2.1.0"
}
group = "moe.jansel"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/content/groups/public/")
}
}
var ktorVersion = "2.3.11"
dependencies {
compileOnly ("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("com.google.code.gson:gson:2.11.0")
// Ktor
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
// Adventure API
implementation("net.kyori:adventure-api:4.17.0")
implementation("net.kyori:adventure-text-minimessage:4.17.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.3")
}
kotlin {
sourceSets["main"].apply {
kotlin.srcDir("src/main/kotlin")
}
jvmToolchain(21)
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
}
}
tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.add("-Xexport-kdoc")
}
}
tasks.shadowJar {
relocate("org.bstats", "moe.jansel")
}

View File

@ -1 +0,0 @@
rootProject.name = 'Platinum'

9
settings.gradle.kts Normal file
View File

@ -0,0 +1,9 @@
pluginManagement {
plugins {
kotlin("jvm") version "2.0.0"
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
rootProject.name = "Platinum"

View File

@ -1,17 +1,14 @@
package moe.jansel.platinum;
package moe.jansel.platinum
import org.bukkit.plugin.java.JavaPlugin;
public final class Platinum extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
import moe.jansel.platinum.commands.PlatinumCommand
import org.bukkit.plugin.java.JavaPlugin
class Platinum : JavaPlugin() {
override fun onEnable() {
getCommand("platinum")!!.setExecutor(PlatinumCommand())
}
@Override
public void onDisable() {
override fun onDisable() {
// Plugin shutdown logic
}
}

View File

@ -0,0 +1,11 @@
package moe.jansel.platinum.commands
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
class PlatinumCommand : CommandExecutor {
override fun onCommand(commandSender: CommandSender, command: Command, s: String, strings: Array<String>): Boolean {
return false
}
}

View File

@ -2,3 +2,30 @@ name: Platinum
version: '${version}'
main: moe.jansel.platinum.Platinum
api-version: '1.20'
prefix: platinum
authors: [ Jansel ]
description: Yet another rewrite of my old datasync Plugin
website: https://git.jansel.moe/jreimers/platinum
commands:
palladium:
usage: /palladium <command> [args]
permissions:
platinum.download:
description: Allows the user to download a file from the provided url
default: false
platinum.copy:
description: Allows the user to copy a downloaded file to the datapack directory
default: false
platinum.info:
description: Allows the user to retrieve the Plugins info
default: false
platinum.admin:
description: Allows the user to use all commands
default: false
children:
- platinum.download
- platinum.copy
- platinum.version