Skip to content

Commit 40888a0

Browse files
committed
🐛 fix error happening on Forge: players getting a message of lacking of permission
1 parent 0162584 commit 40888a0

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

Diff for: script/actor/vaesen.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class VaesenActor extends Actor {
220220
options,
221221
userId
222222
) {
223-
if (game.user.character?._id != this._id) return;
223+
if (!this.isOwner) return;
224224

225225
const addedText = game.i18n.localize("CHANGELOG.ADDED");
226226
await this._handleItem(documents[0], userId, addedText);
@@ -243,7 +243,7 @@ export class VaesenActor extends Actor {
243243
options,
244244
userId
245245
) {
246-
if (game.user.character?._id != this._id) return;
246+
if (!this.isOwner) return;
247247

248248
const removedText = game.i18n.localize("CHANGELOG.REMOVED");
249249
await this._handleItem(documents[0], userId, removedText);

Diff for: script/hooks.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ Hooks.once("init", () => {
7676
registerSystemSettings();
7777
preloadHandlebarsTemplates();
7878

79-
80-
8179
Handlebars.registerHelper("enrichHtmlHelper", function (rawText) {
8280
return TextEditor.enrichHTML(rawText, { async: false });
8381
});
8482

85-
Handlebars.registerHelper('ifIn', function(elem, list, options) {
86-
if(list && list.indexOf(elem) > -1) {
83+
Handlebars.registerHelper('ifIn', function (elem, list, options) {
84+
if (list && list.indexOf(elem) > -1) {
8785
return options.fn(this);
8886
}
8987
return options.inverse(this);
@@ -100,7 +98,7 @@ Hooks.once("init", () => {
10098
});
10199

102100
Hooks.once("ready", async function () {
103-
101+
104102
setupCards();
105103
conditions.onReady();
106104
Hooks.on("hotbarDrop", (bar, data, slot) => createRollMacro(data, slot));
@@ -113,17 +111,16 @@ Hooks.on('canvasReady', () => {
113111
canvas.hud.token = new VaesenTokenHUD();
114112
});
115113

116-
Hooks.on("updateActor", (actor,changes,diff,userId) => {
114+
Hooks.on("updateActor", (actor, changes, diff, userId) => {
117115
// if we don't have an active scene, don't do anything
118-
if (!game.scenes.current) return;
116+
if (!game.scenes.current || !actor.isOwner || changes.name == undefined) return;
119117
console.log("updateActor", actor, changes, diff, userId);
120118
game.scenes.current.tokens.forEach(x => {
121119
if (x.actorId !== actor._id)
122120
return;
123-
if (changes.name !== undefined) {
124-
actor.update({"token.name": actor.name});
125-
x.update({"name": actor.name});
126-
}
121+
122+
actor.update({ "token.name": actor.name });
123+
x.update({ "name": actor.name });
127124
});
128125
});
129126

@@ -136,11 +133,11 @@ Hooks.on('dropActorSheetData', async (actor, sheet, data) => {
136133
sheet._dropHeadquarter(headquarter);
137134
});
138135

139-
Hooks.on("yze-combat.fast-action-button-clicked", async function(data) {
136+
Hooks.on("yze-combat.fast-action-button-clicked", async function (data) {
140137
await conditions.onActionCondition(data);
141138
});
142139

143-
Hooks.on("yze-combat.slow-action-button-clicked", async function(data) {
140+
Hooks.on("yze-combat.slow-action-button-clicked", async function (data) {
144141
await conditions.onActionCondition(data);
145142
});
146143

@@ -247,7 +244,7 @@ async function setupCards() {
247244
const initiativeDeck = game.cards?.get(initiativeDeckId);
248245
//return early if both the deck and the ID exist in the world
249246
if (initiativeDeckId && initiativeDeck)
250-
return;
247+
return;
251248
ui.notifications.info('UI.NoInitiativeDeckFound', { localize: true });
252249
const preset = CONFIG.Cards.presets.initiative;
253250
const data = await foundry.utils.fetchJsonWithTimeout(preset.src);
@@ -343,7 +340,7 @@ actor.sheet.rollWeapon("${data.itemId}");`;
343340
flags: { "vaesen.skillRoll": true }
344341
});
345342
}
346-
343+
347344
game.user.assignHotbarMacro(macro, slot);
348345
return false;
349346
}

0 commit comments

Comments
 (0)