From 39370fcf980fea24779e70c88a78927bea5db921 Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Sun, 24 May 2026 17:38:00 +0200 Subject: [PATCH] fix: guard InterfaceOptionsFrame HookScript, defer TankMode class resolve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On the CoA client the legacy InterfaceOptionsFrame global may be nil (the reworked Settings panel does not always expose it). The unguarded HookScript calls in Castbar.lua and ClassColours.lua then threw on addon load. Wrap both in 'if InterfaceOptionsFrame then ... end', mirroring the guard already present around InterfaceOptionsCombatPanel in Castbar.lua. SetCVars() is still called unconditionally afterwards. TankMode.lua resolved the player's class at file scope with select(2, UnitClass('player')), which on CoA can run before PLAYER_LOGIN — UnitClass returns nil and 'class' stays nil for the whole session, breaking IsTank/IsHealer/Toggle. Move the assignment into mod:OnEnable() (where it is already re-assigned) and leave the file-scope local as nil. Also document that IsTank/IsHealer only know about the vanilla 3.3.5 classes; CoA custom classes fall through to DAMAGER until a CoA-aware tank/healer table is available. --- Kui_Nameplates/Modules/Castbar.lua | 14 ++++++++------ Kui_Nameplates/Modules/ClassColours.lua | 4 +++- Kui_Nameplates/Modules/TankMode.lua | 10 +++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Kui_Nameplates/Modules/Castbar.lua b/Kui_Nameplates/Modules/Castbar.lua index c0ef8c6..5fd09cd 100644 --- a/Kui_Nameplates/Modules/Castbar.lua +++ b/Kui_Nameplates/Modules/Castbar.lua @@ -416,12 +416,14 @@ function mod:OnInitialize() end ) end - InterfaceOptionsFrame:HookScript( - "OnHide", - function() - SetCVars() - end - ) + if InterfaceOptionsFrame then + InterfaceOptionsFrame:HookScript( + "OnHide", + function() + SetCVars() + end + ) + end SetCVars() end diff --git a/Kui_Nameplates/Modules/ClassColours.lua b/Kui_Nameplates/Modules/ClassColours.lua index 7f8402a..5bed92c 100644 --- a/Kui_Nameplates/Modules/ClassColours.lua +++ b/Kui_Nameplates/Modules/ClassColours.lua @@ -106,7 +106,9 @@ function mod:OnInitialize() end end) end - InterfaceOptionsFrame:HookScript("OnHide", function() SetCVars() end) + if InterfaceOptionsFrame then + InterfaceOptionsFrame:HookScript("OnHide", function() SetCVars() end) + end SetCVars() end function mod:OnEnable() diff --git a/Kui_Nameplates/Modules/TankMode.lua b/Kui_Nameplates/Modules/TankMode.lua index a181fbf..e1477ce 100644 --- a/Kui_Nameplates/Modules/TankMode.lua +++ b/Kui_Nameplates/Modules/TankMode.lua @@ -8,7 +8,10 @@ local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates") local mod = addon:NewModule("TankMode", addon.Prototype, "AceEvent-3.0") local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates") -local class, tankmode = select(2, UnitClass("player")), nil +-- `class` is resolved in mod:OnEnable() rather than at file scope: on the CoA +-- client this file can be parsed before PLAYER_LOGIN, when UnitClass("player") +-- returns nil and would otherwise leave `class` permanently nil. +local class, tankmode = nil, nil local profile_tankmode @@ -137,6 +140,10 @@ do return tankTalents >= 3 end + -- NOTE: only vanilla 3.3.5 classes are matched below. CoA custom classes + -- will fall through to DAMAGER in mod:Update(). If a CoA-specific tank / + -- healer class table becomes available we should consult it here instead + -- of (or in addition to) the hard-coded class strings. local function IsTank() return (class == "WARRIOR" and select(3, GetTalentTabInfo(3)) >= 51) or (class == "DEATHKNIGHT" and IsDeathKnightTank()) or @@ -144,6 +151,7 @@ do (class == "DRUID" and select(3, GetTalentTabInfo(2)) >= 51 and IsDruidTank()) end + -- See IsTank() note: CoA custom healer classes fall through to DAMAGER. local function IsHealer() return (class == "PALADIN" and select(3, GetTalentTabInfo(1)) >= 51) or (class == "SHAMAN" and select(3, GetTalentTabInfo(3)) >= 51) or