Skip to content

Commit 95e0c00

Browse files
authored
Merge pull request #572 from YsGqHY/dev/6.2.3-dev
更新 ItemBuilder
2 parents a6da934 + 11893f1 commit 95e0c00

File tree

1 file changed

+12
-9
lines changed
  • module/bukkit/bukkit-util/src/main/kotlin/taboolib/platform/util

1 file changed

+12
-9
lines changed

module/bukkit/bukkit-util/src/main/kotlin/taboolib/platform/util/ItemBuilder.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ import org.bukkit.inventory.ItemStack
1515
import org.bukkit.inventory.meta.*
1616
import org.bukkit.potion.PotionData
1717
import org.bukkit.potion.PotionEffect
18-
import org.tabooproject.reflex.Reflex.Companion.getProperty
1918
import org.tabooproject.reflex.Reflex.Companion.invokeMethod
2019
import taboolib.common.util.random
21-
import taboolib.common5.cint
2220
import taboolib.library.xseries.XAttribute
2321
import taboolib.library.xseries.XMaterial
2422
import taboolib.module.chat.colored
@@ -155,6 +153,8 @@ open class ItemBuilder {
155153
*/
156154
var itemModel: NamespacedKey? = null
157155

156+
var isHideTooltip: Boolean = false
157+
158158
/**
159159
* 唯一化
160160
*/
@@ -294,7 +294,7 @@ open class ItemBuilder {
294294
// CustomModelData
295295
runCatching {
296296
if (customModelData != -1) {
297-
itemMeta.invokeMethod<Void>("setCustomModelData", customModelData)
297+
itemMeta.setCustomModelData(customModelData)
298298
}
299299
}
300300
// Tooltip Style
@@ -305,6 +305,10 @@ open class ItemBuilder {
305305
runCatching {
306306
itemMeta.itemModel = itemModel
307307
}
308+
// Hide Tooltip
309+
runCatching {
310+
itemMeta.isHideTooltip = isHideTooltip
311+
}
308312
// 唯一化
309313
runCatching {
310314
if (unique) {
@@ -401,12 +405,7 @@ open class ItemBuilder {
401405
}
402406
// CustomModelData
403407
runCatching {
404-
val modelData = itemMeta.getProperty<Any>("customModelData")
405-
customModelData = if (modelData is Int) {
406-
itemMeta.getProperty<Int>("customModelData") ?: -1
407-
} else {
408-
modelData?.getProperty<Any>("handle")?.getProperty<List<Float>>("floats")?.firstOrNull()?.cint ?: -1
409-
}
408+
customModelData = itemMeta.customModelData
410409
}
411410
// Tooltip Style
412411
runCatching {
@@ -416,6 +415,10 @@ open class ItemBuilder {
416415
runCatching {
417416
itemModel = itemMeta.itemModel
418417
}
418+
// Hide Tooltip
419+
runCatching {
420+
isHideTooltip = itemMeta.isHideTooltip
421+
}
419422
}
420423
}
421424

0 commit comments

Comments
 (0)