diff --git a/README.md b/README.md index 24ff170..e876338 100644 --- a/README.md +++ b/README.md @@ -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 @@ -34,7 +34,7 @@ dependencies { com.github.DebitCardz mc-chestui-plus - 1.4.9 + 1.5.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 948cb28..b23ce62 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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() diff --git a/src/main/kotlin/me/tech/mcchestui/item/GUIHeadItem.kt b/src/main/kotlin/me/tech/mcchestui/item/GUIHeadItem.kt index e74f4ee..84bc7b6 100644 --- a/src/main/kotlin/me/tech/mcchestui/item/GUIHeadItem.kt +++ b/src/main/kotlin/me/tech/mcchestui/item/GUIHeadItem.kt @@ -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 /** @@ -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. * diff --git a/src/main/kotlin/me/tech/mcchestui/item/GUIItem.kt b/src/main/kotlin/me/tech/mcchestui/item/GUIItem.kt index e3688c8..c969e1c 100644 --- a/src/main/kotlin/me/tech/mcchestui/item/GUIItem.kt +++ b/src/main/kotlin/me/tech/mcchestui/item/GUIItem.kt @@ -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]. */ @@ -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].