Update the preUpdate handling to not block the entire update, bringing it more inline with Armour/Shield
This commit is contained in:
parent
f29ab8bdaa
commit
08278655dc
1 changed files with 10 additions and 8 deletions
|
|
@ -67,19 +67,21 @@ export class WeaponData extends CommonItemData {
|
|||
*/
|
||||
async _preUpdate(changes, options, user) {
|
||||
if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return };
|
||||
|
||||
const diff = diffObject(this.parent._source, changes);
|
||||
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(
|
||||
`RipCrypt.notifs.error.cannot-equip-not-embedded`,
|
||||
`RipCrypt.notifs.error.cannot-equip`,
|
||||
{ itemType: `@TYPES.Item.${this.parent.type}` },
|
||||
));
|
||||
mergeObject(
|
||||
changes,
|
||||
{ "-=system.equipped": null },
|
||||
{ inplace: true, performDeletions: true },
|
||||
);
|
||||
return false;
|
||||
|
||||
// Don't stop the update, but don't allow changing the equipped status
|
||||
setProperty(changes, `system.equipped`, false);
|
||||
|
||||
// Set a flag so that we can tell the sheet that it needs to rerender
|
||||
this.forceRerender = true;
|
||||
};
|
||||
return valid;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue