The problem is here:
Code:
function events:PLAYER_ENTERING_WORLD()
local _, instanceType = IsInInstance()
if instanceType == "arena" then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
for _, trinket in pairs(trinkets) do
trinket:SetCooldown(0, 0)
trinket:Hide()
end
end
end
It's only resetting if you go from arena --> not arena, not if you go from arena --> arena. Since you're probably not reloading your UI in the middle of arena matches, you can just reset every time the event fires:
Code:
function events:PLAYER_ENTERING_WORLD()
local _, instanceType = IsInInstance()
if instanceType == "arena" then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
else
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
for _, trinket in pairs(trinkets) do
trinket:SetCooldown(0, 0)
trinket:Hide()
end
end
Apart from that, though, please put a "local" in front of the "trinkets = {}" line at the top. Otherwise you're putting the generically-named variable "trinkets" in the global namespace, where it's likely to collide with leaked globals from other addons or even the default UI.
If you need/want a global variable for some other purpose, still make "trinkets" local and add a global pointer to it with a more distinct name:
Code:
local trinkets = {} -- keep the generic name local
MyAddonName_Trinkets = trinkets -- export it to a specifically named global