mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-25 08:06:51 +00:00
Fix #599 catch invalid lore lines
This commit is contained in:
@@ -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