Skip to content

Commit

Permalink
fixed shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Oct 20, 2023
1 parent 62cace2 commit 801975c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Item Piles Changelog

## Version 2.7.20 Hotfix

- Fixed item based currencies breaking AGAIN

## Version 2.7.19

- Added support for the Star Wars FFG system (thanks Grumpkin on the Foundry discord server!)
Expand Down
17 changes: 16 additions & 1 deletion src/helpers/compendium-utilities.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import SETTINGS from "../constants/settings.js";
import { getSetting } from "./helpers.js";

const PACK_ID = `world.item-piles-item-backup-do-not-delete`;

const COMPENDIUM_CACHE = {};
Expand All @@ -17,6 +20,19 @@ export async function initializeCompendiumCache() {
}
}

Hooks.on("updateCompendium", updateCache);

updateCache();

}

async function updateCache() {
const currencies = getSetting(SETTINGS.CURRENCIES);
const secondaryCurrencies = getSetting(SETTINGS.SECONDARY_CURRENCIES);
for (const currency of currencies.concat(secondaryCurrencies)) {
if (!currency.data?.uuid) continue;
COMPENDIUM_CACHE[currency.data?.uuid] = (await fromUuid(currency.data.uuid)).toObject();
}
}

export async function getItemCompendium() {
Expand All @@ -42,7 +58,6 @@ export async function findSimilarItemInCompendium(itemToFind) {
}

export function getItemFromCache(uuid) {
if (!game.packs.get(PACK_ID)) return false;
return COMPENDIUM_CACHE[uuid] ?? false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function getActorCurrencies(target, {
item,
index
}
}))
})).filter(Boolean);

cachedActorCurrencies.set(actorUuid, currencies);

Expand Down

0 comments on commit 801975c

Please sign in to comment.