From 4e5f3ed04bb43e962aebd3a59709b329b2a2f062 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Mon, 16 Mar 2026 21:27:15 -0500 Subject: [PATCH] fix: move plugin panel to Database tab + fix WotLKDB 0 counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - QuestieOptionsDatabase: added 'Loaded Questie-X Plugins' section at order 7 For pull-type plugins (WotLKDB) where plugin.stats are all 0, the panel now falls back to counting QuestieDB.*Data directly — this is safe because the name function is called after init completes (user opens the options panel) - QuestieOptionsAdvanced: replaced full plugin panel with redirect note pointing users to the Database tab --- .../AdvancedTab/QuestieOptionsAdvanced.lua | 23 +------ .../DatabaseTab/QuestieOptionsDatabase.lua | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua b/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua index 00d7b82..4a1b3d6 100644 --- a/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua +++ b/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua @@ -429,28 +429,7 @@ function QuestieOptions.tabs.advanced:Initialize() order = 7.01, fontSize = "medium", name = function() - if not QuestiePluginAPI or not QuestiePluginAPI.registeredPlugins then - return "|cFF888888Plugin API not loaded.|r" - end - - local output = "" - local hasPlugins = false - - for pluginName, plugin in pairs(QuestiePluginAPI.registeredPlugins) do - hasPlugins = true - local stats = plugin.stats or {} - output = output .. "|cFF5EBAF3[Questie-" .. pluginName .. "]|r" - output = output .. " Quests: |cFFFFD700" .. tostring(stats.QUEST or 0) .. "|r" - output = output .. " NPCs: |cFFFFD700" .. tostring(stats.NPC or 0) .. "|r" - output = output .. " Objects: |cFFFFD700" .. tostring(stats.OBJECT or 0) .. "|r" - output = output .. " Items: |cFFFFD700" .. tostring(stats.ITEM or 0) .. "|r\n" - end - - if not hasPlugins then - output = "|cFF888888No plugins loaded.|r" - end - - return output + return "|cFF888888Plugin stats have moved to the |r|cFFFFFFFFDatabase|r|cFF888888 tab.|r" end, }, }, diff --git a/Modules/Options/DatabaseTab/QuestieOptionsDatabase.lua b/Modules/Options/DatabaseTab/QuestieOptionsDatabase.lua index 2acdf7f..de16f72 100644 --- a/Modules/Options/DatabaseTab/QuestieOptionsDatabase.lua +++ b/Modules/Options/DatabaseTab/QuestieOptionsDatabase.lua @@ -436,6 +436,74 @@ function QuestieOptions.tabs.database:Initialize() "Submissions are reviewed and merged into the official database. Thank you for contributing!|r" end, }, + + ---- Loaded Plugins ---------------------------------------- + plugins_header = { + type = "header", + order = 7, + name = "|cFF5EBAF3Loaded Questie-X Plugins|r", + }, + + plugins_desc = { + type = "description", + order = 7.1, + fontSize = "medium", + name = function() + local QuestiePluginAPI = QuestieLoader:ImportModule("QuestiePluginAPI") + if not QuestiePluginAPI or not QuestiePluginAPI.registeredPlugins then + return "|cFF888888No plugins loaded.|r" + end + + -- Helper: count a table's entries + local function CountTable(t) + if type(t) ~= "table" then return 0 end + local n = 0 + for _ in pairs(t) do n = n + 1 end + return n + end + + -- For pull-type plugins (e.g. WotLKDB) that never call InjectDatabase, + -- stats stay at 0. Fall back to counting QuestieDB.*Data directly since + -- this function is called after init has completed. + local function GetPluginCounts(pluginName, stats) + local q = stats.QUEST or 0 + local n = stats.NPC or 0 + local o = stats.OBJECT or 0 + local i = stats.ITEM or 0 + + if q == 0 and n == 0 and o == 0 and i == 0 then + local QuestieDB = QuestieLoader:ImportModule("QuestieDB") + if QuestieDB then + q = CountTable(QuestieDB.questData) + n = CountTable(QuestieDB.npcData) + o = CountTable(QuestieDB.objectData) + i = CountTable(QuestieDB.itemData) + end + end + + return q, n, o, i + end + + local output = "" + local hasPlugins = false + + for pluginName, plugin in pairs(QuestiePluginAPI.registeredPlugins) do + hasPlugins = true + local q, n, o, i = GetPluginCounts(pluginName, plugin.stats or {}) + output = output .. "|cFF5EBAF3[Questie-" .. pluginName .. "]|r" + output = output .. " Quests: |cFFFFD700" .. tostring(q) .. "|r" + output = output .. " NPCs: |cFFFFD700" .. tostring(n) .. "|r" + output = output .. " Objects: |cFFFFD700" .. tostring(o) .. "|r" + output = output .. " Items: |cFFFFD700" .. tostring(i) .. "|r\n" + end + + if not hasPlugins then + output = "|cFF888888No plugins loaded.|r" + end + + return output + end, + }, }, } end