@@ -5,25 +5,24 @@ import com.google.common.cache.CacheBuilder
5
5
import me.arasple.mc.trchat.api.event.TrChatItemShowEvent
6
6
import me.arasple.mc.trchat.api.impl.BukkitProxyManager
7
7
import me.arasple.mc.trchat.api.nms.NMS
8
- import me.arasple.mc.trchat.module.adventure.toNative
9
- import me.arasple.mc.trchat.module.adventure.toTranslatableComponentAdventure
10
8
import me.arasple.mc.trchat.module.conf.file.Functions
11
9
import me.arasple.mc.trchat.module.display.function.Function
12
10
import me.arasple.mc.trchat.module.display.function.StandardFunction
13
11
import me.arasple.mc.trchat.module.internal.hook.HookPlugin
14
12
import me.arasple.mc.trchat.module.internal.hook.type.HookDisplayItem
15
13
import me.arasple.mc.trchat.module.internal.script.Reaction
16
14
import me.arasple.mc.trchat.util.*
15
+ import net.kyori.adventure.translation.Translatable
17
16
import org.bukkit.Material
18
17
import org.bukkit.block.ShulkerBox
19
18
import org.bukkit.entity.Player
20
19
import org.bukkit.inventory.Inventory
21
20
import org.bukkit.inventory.ItemStack
22
21
import org.bukkit.inventory.meta.BlockStateMeta
23
- import taboolib.common.UnsupportedVersionException
24
22
import taboolib.common.io.digest
25
23
import taboolib.common.platform.Platform
26
24
import taboolib.common.platform.PlatformSide
25
+ import taboolib.common.platform.function.info
27
26
import taboolib.common.util.asList
28
27
import taboolib.common.util.replaceWithOrder
29
28
import taboolib.common.util.resettableLazy
@@ -37,7 +36,6 @@ import taboolib.module.configuration.ConfigNode
37
36
import taboolib.module.configuration.ConfigNodeTransfer
38
37
import taboolib.module.nms.MinecraftVersion
39
38
import taboolib.module.nms.getI18nName
40
- import taboolib.module.nms.getKey
41
39
import taboolib.module.nms.getLanguageKey
42
40
import taboolib.module.ui.buildMenu
43
41
import taboolib.module.ui.type.Chest
@@ -140,6 +138,7 @@ object ItemShow : Function("ITEM") {
140
138
Components .text(part.text.translate(proxySender).replaceWithOrder(newItem.amount, sha1))
141
139
}
142
140
component.applyStyle(type, part, i, proxySender, newItem.amount, sha1).hoverItemFixed(newItem)
141
+ .also { info(" $i : ${it.toRawMessage()} " ) }
143
142
}
144
143
} else {
145
144
sender.getComponentFromLang(" Function-Item-Show-Format-New" , newItem.amount) { type, i, part, proxySender ->
@@ -206,37 +205,42 @@ object ItemShow : Function("ITEM") {
206
205
207
206
@Suppress(" Deprecation" )
208
207
private fun ItemStack.getNameComponent (player : Player ): ComponentText {
209
- return if (! originName && itemMeta?.hasDisplayName() == true ) {
208
+ if (! originName && itemMeta?.hasDisplayName() == true ) {
209
+ // try {
210
+ // return itemMeta!!.displayName()!!.toNative()
211
+ // } catch (_: Throwable) {
212
+ // }
210
213
try {
211
- Components .empty().append(itemMeta!! .displayName()!! .toNative())
214
+ // 使有效部分在latest
215
+ return Components .empty().append(DefaultComponent (itemMeta!! .displayNameComponent.toList()))
212
216
} catch (_: Throwable ) {
213
- try {
214
- Components .empty().append(DefaultComponent (itemMeta!! .displayNameComponent.toList()))
215
- } catch (_: Throwable ) {
216
- Components .text(itemMeta!! .displayName)
217
- }
218
217
}
219
- } else if (Folia .isFolia) {
220
- toTranslatableComponentAdventure()
218
+ return Components .text(itemMeta!! .displayName)
221
219
} else {
222
- try {
223
- if (MinecraftVersion .isHigherOrEqual(MinecraftVersion .V1_15 )) {
224
- Components .translation(getLanguageKey().path)
225
- } else {
226
- Components .text(getI18nName(player))
227
- }
228
- } catch (_: UnsupportedVersionException ) {
229
- try {
230
- // 玄学问题 https://github.com/TrPlugins/TrChat/issues/344
231
- Components .translation(NMS .instance.getLocaleKey(this ).path)
220
+ if (MinecraftVersion .isHigherOrEqual(MinecraftVersion .V1_15 )) {
221
+ val key = try {
222
+ if (Folia .isFolia) {
223
+ (this as Translatable ).translationKey()
224
+ } else {
225
+ getLanguageKey().path
226
+ }
232
227
} catch (_: Throwable ) {
233
228
try {
234
- Components .text(getKey())
229
+ // 玄学问题 https://github.com/TrPlugins/TrChat/issues/344
230
+ NMS .instance.getLocaleKey(this ).path
235
231
} catch (_: Throwable ) {
236
- Components .text(type.name)
232
+ null
237
233
}
238
234
}
235
+ if (key != null ) {
236
+ return Components .translation(key)
237
+ }
238
+ }
239
+ try {
240
+ return Components .text(getI18nName(player))
241
+ } catch (_: Throwable ) {
239
242
}
243
+ return Components .text(type.name)
240
244
}
241
245
}
242
246
0 commit comments