From b717b0060bedf93754a8a87da95f227f9a21d435 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 19 May 2025 23:22:17 -0600 Subject: [PATCH] Add a user-facing error when the Database is misconfigured. --- module/hooks/init.mjs | 2 +- module/hooks/ready.mjs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 70dfad6..0c8fcfe 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -43,7 +43,7 @@ Hooks.on(`init`, () => { if (import.meta.env.DEV) { CONFIG.stats.db = MemoryDatabase; - } + }; Handlebars.registerHelper(helpers); registerCustomComponents(); diff --git a/module/hooks/ready.mjs b/module/hooks/ready.mjs index ab9ddc3..0e4a0e5 100644 --- a/module/hooks/ready.mjs +++ b/module/hooks/ready.mjs @@ -1,5 +1,13 @@ +import { Database } from "../utils/databases/Database.mjs"; import { Logger } from "../utils/Logger.mjs"; Hooks.on(`ready`, () => { Logger.log(`Version: ${__VERSION__}`); + + // Alert GMs when the configured DB is invalid + if (!(CONFIG.stats.db.prototype instanceof Database) && game.user.isGM) { + ui.notifications.error(`The database handler does not conform to the required heirarchy, the stats tracker module will almost certainly not work correctly.`, { permanent: true }); + } else { + CONFIG.stats.db.registerListeners(); + }; });