From 4fdc6b98c0c3c901ed450e9ef526a77bdc09c053 Mon Sep 17 00:00:00 2001 From: Kim Mantas Date: Thu, 21 Mar 2024 17:43:06 +0000 Subject: [PATCH] Fix issue with deleting a spell that was being concentrated on. --- module/documents/actor/actor.mjs | 4 +++- module/documents/item.mjs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/module/documents/actor/actor.mjs b/module/documents/actor/actor.mjs index e4450bf4eb..3609cdd31f 100644 --- a/module/documents/actor/actor.mjs +++ b/module/documents/actor/actor.mjs @@ -89,7 +89,9 @@ export default class Actor5e extends SystemDocumentMixin(Actor) { const data = effect.getFlag("dnd5e", "itemData"); concentration.effects.add(effect); if ( data ) { - const item = this.items.get(data) ?? new Item.implementation(data, { keepId: true, parent: this }); + const item = typeof data === "string" + ? this.items.get(data) + : new Item.implementation(data, { keepId: true, parent: this }); if ( item ) concentration.items.add(item); } } diff --git a/module/documents/item.mjs b/module/documents/item.mjs index 488a79db78..213ffcc831 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -2451,6 +2451,9 @@ export default class Item5e extends SystemDocumentMixin(Item) { await Item.deleteDocuments(Array.from(contents.map(i => i.id)), { pack: this.pack, parent: this.parent }); } + // End concentration on any effects. + this.parent?.endConcentration?.(this); + // Assign a new original class if ( this.parent && (this.type === "class") && (this.id === this.parent.system.details.originalClass) ) { this.parent._assignPrimaryClass();