From 864194e3b4eebcd8ee5fd953154514e2b976ede9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 24 Nov 2024 16:25:40 +0100 Subject: [PATCH] Correction "lacks permission to update" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correction de message d'erreur 'User ... lacks permission to update Item ... in parent Actor' Causé par le traitement d'un hook onUpdateActor qui semble autorisé à modifier l'actor, mais ne l'est pas - lors de modifications/ajouts de blessures - lors de l'ajout d'effets --- module/misc.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/module/misc.js b/module/misc.js index 76a93ff3..df4301ff 100644 --- a/module/misc.js +++ b/module/misc.js @@ -189,13 +189,7 @@ export class Misc { * and there is no connected GM */ static documentIfResponsible(document) { - if (foundry.utils.isNewerVersion(game.release.version, '12.0')) { - if (game.users.activeGM || (Misc.connectedGMs().length == 0 && Misc.isOwnerPlayer(document))) - { - return document - } - } - else if (Misc.isFirstConnectedGM() || (Misc.connectedGMs().length == 0 && Misc.isOwnerPlayer(document))) { + if (Misc.isFirstConnectedGM() || (Misc.connectedGMs().length == 0 && Misc.isFirstOwnerPlayer(document))) { return document } return undefined @@ -205,8 +199,15 @@ export class Misc { return document.testUserPermission && document.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) } + static isFirstOwnerPlayer(document) { + if (!document.testUserPermission){ + return false + } + return game.users.filter(u => document.testUserPermission(u, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)) == game.user + } + static isOwnerPlayerOrUniqueConnectedGM(actor) { - return Misc.isOwnerPlayer(actor) ?? Misc.isFirstConnectedGM(); + return Misc.isFirstOwnerPlayer(actor) ?? Misc.isFirstConnectedGM(); } /**