Skip to content

Commit c64ad80

Browse files
authored
Merge pull request #119 from Cussa/master
🐛 fix error happening on Forge: players getting a message of lacking …
2 parents 0b1889b + 40888a0 commit c64ad80

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ This system provides character sheets and items for your play, if you would lik
2929

3030

3131
## Release Notes
32+
v4.6.4
33+
- 🐛 fix error happening on Forge: players getting a message of lacking of permission
34+
3235
v4.6.1
3336
- 🐛 system was attempting to update the change log for actors without one which caused changes to fail on NPC and Vaesen actor type [#117](https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/issues/117)
3437
- 🐛 error when updating actors when no scene was active

Diff for: script/actor/vaesen.js

+4
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export class VaesenActor extends Actor {
220220
options,
221221
userId
222222
) {
223+
if (!this.isOwner) return;
224+
223225
const addedText = game.i18n.localize("CHANGELOG.ADDED");
224226
await this._handleItem(documents[0], userId, addedText);
225227

@@ -241,6 +243,8 @@ export class VaesenActor extends Actor {
241243
options,
242244
userId
243245
) {
246+
if (!this.isOwner) return;
247+
244248
const removedText = game.i18n.localize("CHANGELOG.REMOVED");
245249
await this._handleItem(documents[0], userId, removedText);
246250

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
}

Diff for: system.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "Vaesen",
33
"description": "Nordic horror role-playing",
4-
"version": "4.6.3",
4+
"version": "4.6.4",
55
"esmodules": [
66
"script/hooks.js"
77
],

0 commit comments

Comments
 (0)