Skip to content

Commit 7105e58

Browse files
committed
ItemBuilder 全部换成 Throwable
1 parent 6530931 commit 7105e58

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

build.gradle.kts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ fun PublishingExtension.applyToSub(subProject: Project) {
101101
create<BasicAuthentication>("basic")
102102
}
103103
}
104-
maven("http://sacredcraft.cn:8081/repository/releases") {
105-
isAllowInsecureProtocol = true
106-
credentials {
107-
username = project.findProperty("taboolibUsername").toString()
108-
password = project.findProperty("taboolibPassword").toString()
109-
}
110-
authentication {
111-
create<BasicAuthentication>("basic")
112-
}
113-
}
104+
// maven("http://sacredcraft.cn:8081/repository/releases") {
105+
// isAllowInsecureProtocol = true
106+
// credentials {
107+
// username = project.findProperty("taboolibUsername").toString()
108+
// password = project.findProperty("taboolibPassword").toString()
109+
// }
110+
// authentication {
111+
// create<BasicAuthentication>("basic")
112+
// }
113+
// }
114114
mavenLocal()
115115
}
116116
publications {

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ open class ItemBuilder {
274274
// 无法破坏
275275
try {
276276
itemMeta.isUnbreakable = isUnbreakable
277-
} catch (_: NoSuchMethodError) {
277+
} catch (_: Throwable) {
278278
try {
279279
itemMeta.invokeMethod<Any>("spigot")!!.invokeMethod<Any>("setUnbreakable", isUnbreakable)
280280
} catch (_: NoSuchMethodException) {
@@ -285,36 +285,36 @@ open class ItemBuilder {
285285
if (spawnType != null && itemMeta is SpawnEggMeta) {
286286
itemMeta.spawnedType = spawnType
287287
}
288-
} catch (_: NoClassDefFoundError) {
288+
} catch (_: Throwable) {
289289
}
290290
// 旗帜
291291
try {
292292
if (patterns.isNotEmpty() && itemMeta is BannerMeta) {
293293
patterns.forEach { itemMeta.addPattern(it) }
294294
}
295-
} catch (_: NoClassDefFoundError) {
295+
} catch (_: Throwable) {
296296
}
297297
// CustomModelData
298298
try {
299299
if (customModelData != -1) {
300300
itemMeta.setCustomModelData(customModelData)
301301
}
302-
} catch (_: NoSuchMethodError) {
302+
} catch (_: Throwable) {
303303
}
304304
// Tooltip Style
305305
try {
306306
itemMeta.tooltipStyle = tooltipStyle
307-
} catch (_: NoSuchMethodError) {
307+
} catch (_: Throwable) {
308308
}
309309
// ItemModel
310310
try {
311311
itemMeta.itemModel = itemModel
312-
} catch (_: NoSuchMethodError) {
312+
} catch (_: Throwable) {
313313
}
314314
// Hide Tooltip
315315
try {
316316
itemMeta.isHideTooltip = isHideTooltip
317-
} catch (_: NoSuchMethodError) {
317+
} catch (_: Throwable) {
318318
}
319319
// 唯一化
320320
try {
@@ -328,7 +328,7 @@ open class ItemBuilder {
328328
XAttribute.ATTACK_SPEED.get()?.let { itemMeta.addAttributeModifier(it, modifier) }
329329
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES)
330330
}
331-
} catch (_: NoSuchMethodError) {
331+
} catch (_: Throwable) {
332332
}
333333

334334
// 返回
@@ -394,7 +394,7 @@ open class ItemBuilder {
394394
// 无法破坏
395395
try {
396396
isUnbreakable = itemMeta.isUnbreakable
397-
} catch (_: NoSuchMethodError) {
397+
} catch (_: Throwable) {
398398
try {
399399
isUnbreakable = itemMeta.invokeMethod<Any>("spigot")!!.invokeMethod<Boolean>("isUnbreakable") ?: false
400400
} catch (_: NoSuchMethodException) {
@@ -405,38 +405,34 @@ open class ItemBuilder {
405405
if (itemMeta is SpawnEggMeta && itemMeta.spawnedType != null) {
406406
spawnType = itemMeta.spawnedType
407407
}
408-
} catch (_: NoSuchMethodError) {
409-
} catch (_: UnsupportedOperationException) {
408+
} catch (_: Throwable) {
410409
}
411410
// 旗帜
412411
try {
413412
if (itemMeta is BannerMeta && itemMeta.patterns.isNotEmpty()) {
414413
patterns += itemMeta.patterns
415414
}
416-
} catch (_: NoClassDefFoundError) {
415+
} catch (_: Throwable) {
417416
}
418417
// CustomModelData
419418
try {
420-
// 1.21.5+ 必须判断 hasCustomModelData() 否则报错
421-
if (itemMeta.hasCustomModelData()) {
422-
customModelData = itemMeta.customModelData
423-
}
424-
} catch (_: NoSuchMethodError) {
419+
customModelData = itemMeta.customModelData
420+
} catch (_: Throwable) {
425421
}
426422
// Tooltip Style
427423
try {
428424
tooltipStyle = itemMeta.tooltipStyle
429-
} catch (_: NoSuchMethodError) {
425+
} catch (_: Throwable) {
430426
}
431427
// ItemModel
432428
try {
433429
itemModel = itemMeta.itemModel
434-
} catch (_: NoSuchMethodError) {
430+
} catch (_: Throwable) {
435431
}
436432
// Hide Tooltip
437433
try {
438434
isHideTooltip = itemMeta.isHideTooltip
439-
} catch (_: NoSuchMethodError) {
435+
} catch (_: Throwable) {
440436
}
441437
}
442438
}

0 commit comments

Comments
 (0)