From af1f4d62985601bbdde05cdec4889bda7e794a85 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 13 Jan 2020 12:13:55 +0100 Subject: [PATCH] Add files via upload fixed a bug that prevented proper load order if `renderCompendiumDirectory` gets called during `init` --- compendium-browser.js | 13 +++++++++---- module.json | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compendium-browser.js b/compendium-browser.js index 8a2542d..2498557 100644 --- a/compendium-browser.js +++ b/compendium-browser.js @@ -1,6 +1,6 @@ /** * @author Felix Müller aka syl3r86 - * @version 0.1.5 + * @version 0.1.9 */ class SpellBrowser extends Application { @@ -10,7 +10,9 @@ class SpellBrowser extends Application { // load settings Hooks.on('ready', e => { - this.initSettings(); + if (this.settings === undefined) { + this.initSettings(); + } this.loadSpells().then(obj => { this.spells = obj @@ -53,6 +55,9 @@ class SpellBrowser extends Application { hookCompendiumList() { Hooks.on('renderCompendiumDirectory', (app, html, data) => { + if (this.settings === undefined) { + this.initSettings(); + } if (game.user.isGM || this.settings.allowSpellBrowser || this.settings.allowNpcBrowser) { const importButton = $(``); html.find('.compendium-browser-btn').remove(); @@ -646,7 +651,7 @@ class SpellBrowser extends Application { this.settings = settings; } }); - + // load settings from container and apply to default settings (available compendie might have changed) let settings = game.settings.get('compendiumBrowser', 'settings'); for (let compKey in defaultSettings.loadedSpellCompendium) { @@ -661,7 +666,7 @@ class SpellBrowser extends Application { } defaultSettings.allowSpellBrowser = settings.allowSpellBrowser; defaultSettings.allowNpcBrowser = settings.allowNpcBrowser; - + game.settings.set('compendiumBrowser', 'settings', defaultSettings); this.settings = defaultSettings; } diff --git a/module.json b/module.json index b18fe27..f2a69bb 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "compendium-browser", "title": "Compendium Browser", "description": "A module to easily browse and filter spells as well as npcs loaded from compendie.", - "version": "0.1.8", + "version": "0.1.9", "author": "Felix#6196", "systems": ["dnd5e"], "scripts": ["./compendium-browser.js"],