Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix error happening on Forge: players getting a message of lacking … #119

Merged
merged 2 commits into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,9 @@ This system provides character sheets and items for your play, if you would lik


## Release Notes
v4.6.4
- 🐛 fix error happening on Forge: players getting a message of lacking of permission

v4.6.1
- 🐛 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)
- 🐛 error when updating actors when no scene was active
Expand Down
4 changes: 4 additions & 0 deletions script/actor/vaesen.js
Expand Up @@ -220,6 +220,8 @@ export class VaesenActor extends Actor {
options,
userId
) {
if (!this.isOwner) return;

const addedText = game.i18n.localize("CHANGELOG.ADDED");
await this._handleItem(documents[0], userId, addedText);

Expand All @@ -241,6 +243,8 @@ export class VaesenActor extends Actor {
options,
userId
) {
if (!this.isOwner) return;

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

Expand Down
27 changes: 12 additions & 15 deletions script/hooks.js
Expand Up @@ -76,14 +76,12 @@ Hooks.once("init", () => {
registerSystemSettings();
preloadHandlebarsTemplates();



Handlebars.registerHelper("enrichHtmlHelper", function (rawText) {
return TextEditor.enrichHTML(rawText, { async: false });
});

Handlebars.registerHelper('ifIn', function(elem, list, options) {
if(list && list.indexOf(elem) > -1) {
Handlebars.registerHelper('ifIn', function (elem, list, options) {
if (list && list.indexOf(elem) > -1) {
return options.fn(this);
}
return options.inverse(this);
Expand All @@ -100,7 +98,7 @@ Hooks.once("init", () => {
});

Hooks.once("ready", async function () {

setupCards();
conditions.onReady();
Hooks.on("hotbarDrop", (bar, data, slot) => createRollMacro(data, slot));
Expand All @@ -113,17 +111,16 @@ Hooks.on('canvasReady', () => {
canvas.hud.token = new VaesenTokenHUD();
});

Hooks.on("updateActor", (actor,changes,diff,userId) => {
Hooks.on("updateActor", (actor, changes, diff, userId) => {
// if we don't have an active scene, don't do anything
if (!game.scenes.current) return;
if (!game.scenes.current || !actor.isOwner || changes.name == undefined) return;
console.log("updateActor", actor, changes, diff, userId);
game.scenes.current.tokens.forEach(x => {
if (x.actorId !== actor._id)
return;
if (changes.name !== undefined) {
actor.update({"token.name": actor.name});
x.update({"name": actor.name});
}

actor.update({ "token.name": actor.name });
x.update({ "name": actor.name });
});
});

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

Hooks.on("yze-combat.fast-action-button-clicked", async function(data) {
Hooks.on("yze-combat.fast-action-button-clicked", async function (data) {
await conditions.onActionCondition(data);
});

Hooks.on("yze-combat.slow-action-button-clicked", async function(data) {
Hooks.on("yze-combat.slow-action-button-clicked", async function (data) {
await conditions.onActionCondition(data);
});

Expand Down Expand Up @@ -247,7 +244,7 @@ async function setupCards() {
const initiativeDeck = game.cards?.get(initiativeDeckId);
//return early if both the deck and the ID exist in the world
if (initiativeDeckId && initiativeDeck)
return;
return;
ui.notifications.info('UI.NoInitiativeDeckFound', { localize: true });
const preset = CONFIG.Cards.presets.initiative;
const data = await foundry.utils.fetchJsonWithTimeout(preset.src);
Expand Down Expand Up @@ -343,7 +340,7 @@ actor.sheet.rollWeapon("${data.itemId}");`;
flags: { "vaesen.skillRoll": true }
});
}

game.user.assignHotbarMacro(macro, slot);
return false;
}
2 changes: 1 addition & 1 deletion system.json
@@ -1,7 +1,7 @@
{
"title": "Vaesen",
"description": "Nordic horror role-playing",
"version": "4.6.3",
"version": "4.6.4",
"esmodules": [
"script/hooks.js"
],
Expand Down