From 61f67346f48f83e5a9a17b9bd5b1c439ead08375 Mon Sep 17 00:00:00 2001 From: akkih Date: Thu, 16 May 2024 20:17:13 -0300 Subject: [PATCH 1/2] feat: add metadata extensions --- .../flyte/twilight/extension/LivingEntity.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/kotlin/gg/flyte/twilight/extension/LivingEntity.kt b/src/main/kotlin/gg/flyte/twilight/extension/LivingEntity.kt index 49e1bd4..8bbef35 100644 --- a/src/main/kotlin/gg/flyte/twilight/extension/LivingEntity.kt +++ b/src/main/kotlin/gg/flyte/twilight/extension/LivingEntity.kt @@ -1,9 +1,11 @@ package gg.flyte.twilight.extension +import gg.flyte.twilight.Twilight import org.bukkit.Location import org.bukkit.Material import org.bukkit.attribute.Attribute import org.bukkit.entity.LivingEntity +import org.bukkit.metadata.FixedMetadataValue /** * Kills the living entity. @@ -47,4 +49,23 @@ fun LivingEntity.isOnLadder(): Boolean { */ fun LivingEntity.teleport(x: Number, y: Number, z: Number) { teleport(Location(world, x.toDouble(), y.toDouble(), z.toDouble())) +} + +/** + * Sets a metadata value in the implementing object's metadata store. + * + * @param key A unique key to identify this metadata. + * @param value The metadata value to apply. + */ +fun LivingEntity.setMetadata(key: String, value: Any) { + setMetadata(key, FixedMetadataValue(Twilight.plugin, value)) +} + +/** + * Removes the given metadata value from the implementing object's metadata store. + * + * @param key The unique metadata key identifying the metadata to remove. + */ +fun LivingEntity.removeMetadata(key: String) { + removeMetadata(key, Twilight.plugin) } \ No newline at end of file From a84575fb4604144921a5381ba2fefc0ec5e7fc80 Mon Sep 17 00:00:00 2001 From: Josh <43449531+joshbker@users.noreply.github.com> Date: Sun, 19 May 2024 19:41:42 +0100 Subject: [PATCH 2/2] chore: bump ver v1.1.12 --- README.md | 6 +++--- build.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7d9a3d8..b6d067e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Maven gg.flyte twilight - 1.1.11 + 1.1.12 ``` @@ -33,14 +33,14 @@ maven { url "https://repo.flyte.gg/releases" } -implementation "gg.flyte:twilight:1.1.11" +implementation "gg.flyte:twilight:1.1.12" ``` Gradle (Kotlin DSL) ```kotlin maven("https://repo.flyte.gg/releases") -implementation("gg.flyte:twilight:1.1.11") +implementation("gg.flyte:twilight:1.1.12") ``` Certain features of Twilight require configuration, which can be done via the Twilight class. To setup a Twilight class instance, you can use the `twilight` function as shown below: diff --git a/build.gradle.kts b/build.gradle.kts index a759b4d..44527d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "gg.flyte" -version = "1.1.11" +version = "1.1.12" repositories { mavenLocal()