Skip to content

更新 ItemBuilder #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.*
import org.bukkit.potion.PotionData
import org.bukkit.potion.PotionEffect
import org.tabooproject.reflex.Reflex.Companion.getProperty
import org.tabooproject.reflex.Reflex.Companion.invokeMethod
import taboolib.common.util.random
import taboolib.common5.cint
import taboolib.library.xseries.XAttribute
import taboolib.library.xseries.XMaterial
import taboolib.module.chat.colored
Expand Down Expand Up @@ -155,6 +153,8 @@ open class ItemBuilder {
*/
var itemModel: NamespacedKey? = null

var isHideTooltip: Boolean = false

/**
* 唯一化
*/
Expand Down Expand Up @@ -294,7 +294,7 @@ open class ItemBuilder {
// CustomModelData
runCatching {
if (customModelData != -1) {
itemMeta.invokeMethod<Void>("setCustomModelData", customModelData)
itemMeta.setCustomModelData(customModelData)
}
}
// Tooltip Style
Expand All @@ -305,6 +305,10 @@ open class ItemBuilder {
runCatching {
itemMeta.itemModel = itemModel
}
// Hide Tooltip
runCatching {
itemMeta.isHideTooltip = isHideTooltip
}
// 唯一化
runCatching {
if (unique) {
Expand Down Expand Up @@ -401,12 +405,7 @@ open class ItemBuilder {
}
// CustomModelData
runCatching {
val modelData = itemMeta.getProperty<Any>("customModelData")
customModelData = if (modelData is Int) {
itemMeta.getProperty<Int>("customModelData") ?: -1
} else {
modelData?.getProperty<Any>("handle")?.getProperty<List<Float>>("floats")?.firstOrNull()?.cint ?: -1
}
customModelData = itemMeta.customModelData
}
// Tooltip Style
runCatching {
Expand All @@ -416,6 +415,10 @@ open class ItemBuilder {
runCatching {
itemModel = itemMeta.itemModel
}
// Hide Tooltip
runCatching {
isHideTooltip = itemMeta.isHideTooltip
}
}
}

Expand Down