Improved registration and unregistration of triggers

This commit is contained in:
WBHarry 2026-01-15 21:52:22 +01:00
parent 9393bab6cf
commit 9fb9ae1b91
5 changed files with 129 additions and 27 deletions

View file

@ -208,4 +208,18 @@ export default class DHItem extends foundry.documents.Item {
cls.create(msg);
}
deleteTriggers() {
const actions = Array.from(this.system.actions ?? []);
if (!actions.length) return;
game.system.registeredTriggers.unregisterTriggers(
actions.flatMap(action => action.triggers.map(x => x.trigger)),
this.uuid
);
}
async _preDelete() {
this.deleteTriggers();
}
}