mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Fix #599 catch invalid lore lines
This commit is contained in:
@@ -115,7 +115,7 @@ export function ItemTooltip({ item, advanced, resolver }: Props) {
|
||||
: <TextComponent component={{ translate: 'item.dyed', color: 'gray' }} />
|
||||
)}
|
||||
{item.getLore().map((component) =>
|
||||
<TextComponent component={JSON.parse(component)} base={{ color: 'dark_purple', italic: true }} />
|
||||
<TextComponent component={component} base={{ color: 'dark_purple', italic: true }} />
|
||||
)}
|
||||
{item.showInTooltip('attribute_modifiers') && (
|
||||
<AttributeModifiersTooltip data={item.get('attribute_modifiers', tag => tag)} />
|
||||
|
||||
@@ -107,7 +107,13 @@ export class ResolvedItem extends ItemStack {
|
||||
|
||||
public getLore() {
|
||||
return this.get('lore', tag => {
|
||||
return tag.isList() ? tag.map(e => e.getAsString()) : []
|
||||
return tag.isList() ? tag.map(e => {
|
||||
try {
|
||||
return JSON.parse(e.getAsString())
|
||||
} catch (e) {
|
||||
return { text: '(invalid lore line)' }
|
||||
}
|
||||
}) : []
|
||||
}) ?? []
|
||||
}
|
||||
|
||||
@@ -160,11 +166,13 @@ export class ResolvedItem extends ItemStack {
|
||||
}
|
||||
|
||||
const itemName = this.get('item_name', tag => tag.isString() ? tag.getAsString() : undefined)
|
||||
try {
|
||||
if (itemName) {
|
||||
if (itemName) {
|
||||
try {
|
||||
return JSON.parse(itemName)
|
||||
} catch (e) {
|
||||
return { text: '(invalid item name)' }
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const guess = this.id.path
|
||||
.replace(/[_\/]/g, ' ')
|
||||
|
||||
Reference in New Issue
Block a user