Skip to content

Commit

Permalink
Implement Meta (#26)
Browse files Browse the repository at this point in the history
* feat: meta

* misc: bump version
  • Loading branch information
DebitCardz authored Feb 29, 2024
1 parent 17fd727 commit 68fa036
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
}

dependencies {
implementation("com.github.DebitCardz:mc-chestui-plus:1.4.9")
implementation("com.github.DebitCardz:mc-chestui-plus:1.5.0")
}
```
### Maven
Expand All @@ -34,7 +34,7 @@ dependencies {
<dependency>
<groupId>com.github.DebitCardz</groupId>
<artifactId>mc-chestui-plus</artifactId>
<version>1.4.9</version>
<version>1.5.0</version>
</dependency>

```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ val githubActor = project.findProperty("gpr.user") as String? ?: System.getenv("
val githubToken = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")

group = "me.tech"
version = "1.4.9"
version = "1.5.0"

repositories {
mavenCentral()
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/me/tech/mcchestui/item/GUIHeadItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import me.tech.mcchestui.GUI
import org.bukkit.Material
import org.bukkit.OfflinePlayer
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.inventory.meta.SkullMeta

/**
Expand Down Expand Up @@ -33,6 +34,14 @@ class GUIHeadItem : GUIItem(Material.PLAYER_HEAD) {
override val itemMeta: SkullMeta
get() = stack.itemMeta as SkullMeta

/**
* Modify the [SkullMeta] of the [GUIItem].
* @param builder [SkullMeta] builder.
*/
fun meta(builder: SkullMeta.() -> Unit) {
itemStack.editMeta(SkullMeta::class.java, builder)
}

/**
* Current [OfflinePlayer] that owns the player head.
*
Expand Down
28 changes: 28 additions & 0 deletions src/main/kotlin/me/tech/mcchestui/item/GUIItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ open class GUIItem constructor(
itemStack.type = material
}

/**
* Modify the [ItemMeta] of the [GUIItem].
* @param builder [ItemMeta] builder.
*/
fun meta(builder: ItemMeta.() -> Unit) {
itemStack.editMeta(builder)
}

/**
* Current display name of the [ItemStack].
*/
Expand Down Expand Up @@ -161,6 +169,26 @@ open class GUIItem constructor(
}
}

/**
* Add [ItemFlag] to the [ItemStack].
* @param flags [ItemFlag] to add.
*/
fun addFlags(vararg flags: ItemFlag) {
itemStack.editMeta {
it.addItemFlags(*flags)
}
}

/**
* Remove [ItemFlag] from the [ItemStack].
* @param flags [ItemFlag] to remove.
*/
fun removeFlags(vararg flags: ItemFlag) {
itemStack.editMeta {
it.removeItemFlags(*flags)
}
}

/**
* Remove the italics of a [Component] if it is not already
* set on the [Component].
Expand Down

0 comments on commit 68fa036

Please sign in to comment.