Skip to content

Commit

Permalink
Merge pull request #69 from flytegg/pr/metadata
Browse files Browse the repository at this point in the history
Pr/metadata
  • Loading branch information
joshbker authored May 19, 2024
2 parents 5cc0c06 + a84575f commit 65ced5e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Maven
<dependency>
<groupId>gg.flyte</groupId>
<artifactId>twilight</artifactId>
<version>1.1.11</version>
<version>1.1.12</version>
</dependency>
```

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "gg.flyte"
version = "1.1.11"
version = "1.1.12"

repositories {
mavenLocal()
Expand Down
21 changes: 21 additions & 0 deletions src/main/kotlin/gg/flyte/twilight/extension/LivingEntity.kt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
}

0 comments on commit 65ced5e

Please sign in to comment.