feat: CustomModelDataComponent

This commit is contained in:
2025-12-04 02:48:57 -07:00
parent 5ae8da7f10
commit 98913e1690
2 changed files with 8 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "net.axay" group = "net.axay"
version = "1.21.8-VAL" version = "1.21.8.2-VAL"
description = "A Kotlin API for Minecraft plugins using the Spigot or Paper toolchain" description = "A Kotlin API for Minecraft plugins using the Spigot or Paper toolchain"

View File

@@ -11,6 +11,7 @@ import org.bukkit.Material
import org.bukkit.inventory.ItemFlag import org.bukkit.inventory.ItemFlag
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.inventory.meta.components.CustomModelDataComponent
/** /**
* Creates a new [ItemStack] and opens a builder for it. * Creates a new [ItemStack] and opens a builder for it.
@@ -129,21 +130,16 @@ var ItemMeta.name: Component?
get() = if (hasDisplayName()) displayName() else null get() = if (hasDisplayName()) displayName() else null
set(value) = displayName(value ?: Component.space()) set(value) = displayName(value ?: Component.space())
/** //var ItemMeta.customModel: Int?
* Provides safe access to the items' displayName. // get() = if (hasCustomModelData()) customModelData else null
*/ // set(value) = setCustomModelData(value)
@Suppress("DEPRECATION")
@Deprecated("displaynames are saved as Components in Paper", ReplaceWith("name", "net.axay.kspigot.Items.name"))
var ItemMeta.stringName: String?
get() = if (hasDisplayName()) displayName else null
set(value) = setDisplayName(if (value == null || value == "") " " else value)
/** /**
* Provides safe access to the items' customModelData. * Provides safe access to the items' customModelData.
*/ */
var ItemMeta.customModel: Int? var ItemMeta.customModel: CustomModelDataComponent?
get() = if (hasCustomModelData()) customModelData else null get() = if (hasCustomModelDataComponent()) customModelDataComponent else null
set(value) = setCustomModelData(value) set(value) = setCustomModelDataComponent(value)
/** /**
* Provides more consistent access to the items' localizedName. * Provides more consistent access to the items' localizedName.