Skip to content

Commit

Permalink
Fix non-item UUIDs breaking spell sheet
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
oWave committed Dec 24, 2024
1 parent 3dd84ff commit 79fe7ca
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/emanation/emanation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ async function extractEffects(item: SpellPF2e) {
const uuids = extractEffectUUIDs(item)
if (!uuids) return []

const effects = (await Promise.all(uuids.map((id) => fromUuid<ItemPF2e>(id)))).filter((e) =>
e?.isOfType("effect"),
const effects = (await Promise.all(uuids.map((id) => fromUuid<ItemPF2e>(id)))).filter(
(e) => typeof e?.isOfType === "function" && e?.isOfType("effect"),
)
return effects
}
Expand Down Expand Up @@ -162,7 +162,12 @@ async function spellSheetRenderInner(sheet: SpellSheetPF2e, $html: JQuery) {
async function spellSheetRenderWrapper(this: SpellSheetPF2e, wrapped, ...args) {
const $html = await wrapped(...args)

if (MODULE.settings.emanationAutomation) await spellSheetRenderInner(this, $html)
try {
if (MODULE.settings.emanationAutomation) await spellSheetRenderInner(this, $html)
} catch (e) {
ui.notifications.error("Could not insert emanation automation into spell sheet.")
console.error(e)
}

return $html
}
Expand Down

0 comments on commit 79fe7ca

Please sign in to comment.