From 967b3ba2abeeb81db41ccbe7ed202ed2f6c124ea Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 24 Jul 2025 12:47:57 +0200 Subject: [PATCH] Fixed our onCreate methods unintentionally being run on all clients --- module/data/activeEffect/beastformEffect.mjs | 4 +++- module/data/item/base.mjs | 4 +++- module/data/item/beastform.mjs | 4 +++- module/data/item/class.mjs | 3 +++ module/data/item/subclass.mjs | 2 ++ module/documents/tooltipManager.mjs | 2 +- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/module/data/activeEffect/beastformEffect.mjs b/module/data/activeEffect/beastformEffect.mjs index 4e6fa104..91b84614 100644 --- a/module/data/activeEffect/beastformEffect.mjs +++ b/module/data/activeEffect/beastformEffect.mjs @@ -26,7 +26,9 @@ export default class BeastformEffect extends foundry.abstract.TypeDataModel { }; } - async _onCreate() { + async _onCreate(_data, _options, userId) { + if (userId !== game.user.id) return; + if (this.parent.parent?.type === 'character') { this.parent.parent.system.primaryWeapon?.update?.({ 'system.equipped': false }); this.parent.parent.system.secondayWeapon?.update?.({ 'system.equipped': false }); diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index d4a3b9b6..09edfb58 100644 --- a/module/data/item/base.mjs +++ b/module/data/item/base.mjs @@ -118,7 +118,9 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel { } } - _onCreate(data) { + _onCreate(data, _, userId) { + if (userId !== game.user.id) return; + if (!this.actor || this.actor.type !== 'character' || !this.features) return; this.actor.createEmbeddedDocuments( diff --git a/module/data/item/beastform.mjs b/module/data/item/beastform.mjs index 226504df..0dca8883 100644 --- a/module/data/item/beastform.mjs +++ b/module/data/item/beastform.mjs @@ -149,7 +149,9 @@ export default class DHBeastform extends BaseDataItem { return false; } - _onCreate() { + _onCreate(_data, _options, userId) { + if (userId !== game.user.id) return; + this.parent.createEmbeddedDocuments('ActiveEffect', [ { type: 'beastform', diff --git a/module/data/item/class.mjs b/module/data/item/class.mjs index c18728fa..a8b8dffa 100644 --- a/module/data/item/class.mjs +++ b/module/data/item/class.mjs @@ -75,6 +75,9 @@ export default class DHClass extends BaseDataItem { _onCreate(data, options, userId) { super._onCreate(data, options, userId); + + if (userId !== game.user.id) return; + if (options.parent?.type === 'character') { const path = `system.${data.system.isMulticlass ? 'multiclass.value' : 'class.value'}`; options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` }); diff --git a/module/data/item/subclass.mjs b/module/data/item/subclass.mjs index b5073cbc..ed6f8b45 100644 --- a/module/data/item/subclass.mjs +++ b/module/data/item/subclass.mjs @@ -67,6 +67,8 @@ export default class DHSubclass extends BaseDataItem { _onCreate(data, options, userId) { super._onCreate(data, options, userId); + if (userId !== game.user.id) return; + if (options.parent?.type === 'character') { const path = `system.${data.system.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`; options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` }); diff --git a/module/documents/tooltipManager.mjs b/module/documents/tooltipManager.mjs index 8e1c729e..ab3d40ea 100644 --- a/module/documents/tooltipManager.mjs +++ b/module/documents/tooltipManager.mjs @@ -13,7 +13,7 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti if (item) { const type = actionId ? 'action' : item.type; const description = await TextEditor.enrichHTML(item.system.description); - for (let feature of item.system.features) { + for (let feature of item.system?.features ?? []) { feature.system.enrichedDescription = await TextEditor.enrichHTML(feature.system.description); }