From 167a3d5894cad9f8c67057eb4c266a8014475512 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 30 Jan 2022 16:11:20 +0100 Subject: [PATCH] Count worlds instance --- module/rdd-main.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/module/rdd-main.js b/module/rdd-main.js index 1c7321c9..ad2e559d 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -217,6 +217,28 @@ function messageDeBienvenue() { } } +/* -------------------------------------------- */ +// Register world usage statistics +function registerUsageCount( registerKey ) { + if ( game.user.isGM ) { + game.settings.register(registerKey, "world-key", { + name: "Unique world key", + scope: "world", + config: false, + type: String + }); + + let worldKey = game.settings.get(registerKey, "world-key") + if ( worldKey == undefined || worldKey == "" ) { + worldKey = randomID(32) + game.settings.set(registerKey, "world-key", worldKey ) + } + // Simple API counter + $.ajax(`https://jdr.lahiette.com/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`) + /* -------------------------------------------- */ + } +} + /* -------------------------------------------- */ /* Foundry VTT Initialization */ /* -------------------------------------------- */ @@ -246,6 +268,7 @@ Hooks.once("ready", async function () { } if (Misc.isUniqueConnectedGM()) { messageDeBienvenue(); + registerUsageCount( SYSTEM_RDD ); } }); @@ -282,6 +305,7 @@ async function migrationPngWebp_1_5_34() { let sidebar = document.getElementById("sidebar"); sidebar.style.width = "min-content"; } + } /* -------------------------------------------- */