Update the preUpdate handling to not block the entire update, bringing it more inline with Armour/Shield

This commit is contained in:
Eldritch-Oliver 2025-10-05 15:25:52 -06:00
parent f29ab8bdaa
commit 08278655dc

View file

@ -67,19 +67,21 @@ export class WeaponData extends CommonItemData {
*/ */
async _preUpdate(changes, options, user) { async _preUpdate(changes, options, user) {
if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return }; if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return };
const diff = diffObject(this.parent._source, changes);
let valid = super._preUpdate(changes, options, user); let valid = super._preUpdate(changes, options, user);
if (hasProperty(changes, `system.equipped`) && !this.parent.isEmbedded) { if (getProperty(diff, `system.equipped`) && !this._canEquip()) {
ui.notifications.error(localizer( ui.notifications.error(localizer(
`RipCrypt.notifs.error.cannot-equip-not-embedded`, `RipCrypt.notifs.error.cannot-equip`,
{ itemType: `@TYPES.Item.${this.parent.type}` }, { itemType: `@TYPES.Item.${this.parent.type}` },
)); ));
mergeObject(
changes, // Don't stop the update, but don't allow changing the equipped status
{ "-=system.equipped": null }, setProperty(changes, `system.equipped`, false);
{ inplace: true, performDeletions: true },
); // Set a flag so that we can tell the sheet that it needs to rerender
return false; this.forceRerender = true;
}; };
return valid; return valid;
}; };