From c4603bae607700ee984841f9d9e13b5c80e29791 Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Wed, 28 Jun 2023 11:41:26 +0200 Subject: [PATCH] Port to 1.20 with a paper plugin --- build.gradle.kts | 19 ++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/kotlin/nl/kallestruik/dlib/DLib.kt | 4 +--- .../kallestruik/dlib/gui/TextInputDialog.kt | 5 ++++- .../{plugin.yml => paper-plugin.yml} | 6 +++--- 5 files changed, 19 insertions(+), 17 deletions(-) rename src/main/resources/{plugin.yml => paper-plugin.yml} (62%) diff --git a/build.gradle.kts b/build.gradle.kts index 99fd87f..ba2e117 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,29 +1,30 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.7.10" - kotlin("plugin.serialization") version "1.7.0" + kotlin("jvm") version "1.8.22" + kotlin("plugin.serialization") version "1.8.22" id("maven-publish") - id("com.github.johnrengelman.shadow") version "7.1.2" - id("io.papermc.paperweight.userdev") version "1.3.8" + id("com.github.johnrengelman.shadow") version "8.1.1" + id("io.papermc.paperweight.userdev") version "1.5.5" } group = "nl.kallestruik" -version = "1.5.0" +version = "1.5.1" repositories { mavenCentral() } dependencies { - paperDevBundle("1.19-R0.1-SNAPSHOT") + paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT") implementation(kotlin("reflect")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") implementation("org.jetbrains.kotlin:kotlin-scripting-common") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host") + implementation("net.kyori:adventure-text-serializer-plain:4.14.0") testImplementation(kotlin("test-junit5")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") @@ -87,4 +88,4 @@ kotlin { languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi") } } -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b5..1f017e4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/nl/kallestruik/dlib/DLib.kt b/src/main/kotlin/nl/kallestruik/dlib/DLib.kt index 169a009..50ba584 100644 --- a/src/main/kotlin/nl/kallestruik/dlib/DLib.kt +++ b/src/main/kotlin/nl/kallestruik/dlib/DLib.kt @@ -1,10 +1,8 @@ package nl.kallestruik.dlib -import net.kyori.adventure.text.Component -import nl.kallestruik.dlib.gui.chestGUI import org.bukkit.plugin.java.JavaPlugin /** * This class is only here to make sure that paper loads the plugin. */ -class DLib: JavaPlugin() \ No newline at end of file +class DLib: JavaPlugin() diff --git a/src/main/kotlin/nl/kallestruik/dlib/gui/TextInputDialog.kt b/src/main/kotlin/nl/kallestruik/dlib/gui/TextInputDialog.kt index 64bff2a..7de524f 100644 --- a/src/main/kotlin/nl/kallestruik/dlib/gui/TextInputDialog.kt +++ b/src/main/kotlin/nl/kallestruik/dlib/gui/TextInputDialog.kt @@ -2,6 +2,7 @@ package nl.kallestruik.dlib.gui import kotlinx.coroutines.runBlocking import net.kyori.adventure.text.Component +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -116,7 +117,9 @@ class TextInputDialog: Listener { } val item = event.currentItem - val name = item?.itemMeta?.displayName ?: "" + val nameComponent = item?.itemMeta?.displayName() ?: Component.empty() + + val name = PlainTextComponentSerializer.plainText().serialize(nameComponent) if (name == "") { event.isCancelled = true diff --git a/src/main/resources/plugin.yml b/src/main/resources/paper-plugin.yml similarity index 62% rename from src/main/resources/plugin.yml rename to src/main/resources/paper-plugin.yml index ff037b0..fc49863 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -1,4 +1,4 @@ -name: "DLib" -main: nl.kallestruik.dlib.DLib +name: DLib version: ${version} -api-version: 1.16 \ No newline at end of file +main: nl.kallestruik.dlib.DLib +api-version: '1.20'