From 7ecb7d541172e9604363d12b8304932d2066f409 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 30 Sep 2018 14:16:51 +0200 Subject: [PATCH] libdebuff: use proper invocation of UnitDebuff --- api/tbc.lua | 6 +++++- libs/libdebuff.lua | 6 +++--- modules/nameplates.lua | 11 +++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/api/tbc.lua b/api/tbc.lua index 6596fd9c..314ae450 100644 --- a/api/tbc.lua +++ b/api/tbc.lua @@ -47,7 +47,11 @@ function pfUI.api.UnitDebuff(unitstr, i) end -- use native UnitDebuff instead of libdebuff emulation -pfUI.api.libdebuff = { ["UnitDebuff"] = _G.UnitDebuff } +pfUI.api.libdebuff = { + ["UnitDebuff"] = function(self, unit, i) + return _G.UnitDebuff(unit, i) + end +} -- blacklist unrequired modules pfUI.module.autoshift = true diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index c54d05dd..ef29a770 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -145,16 +145,16 @@ libdebuff:SetScript("OnEvent", function() for unit, effect in gfind(arg1, libdebuff.combatlog) do local unitlevel = UnitName("target") == unit and UnitLevel("target") or 0 if not libdebuff.objects[unit] or not libdebuff.objects[unit][unitlevel] or not libdebuff.objects[unit][unitlevel][effect] then - this:AddEffect(unit, unitlevel, effect) + libdebuff:AddEffect(unit, unitlevel, effect) end end -- Add Missing Buffs by Iteration elseif ( event == "UNIT_AURA" and arg1 == "target" ) or event == "PLAYER_TARGET_CHANGED" then for i=1, 16 do - effect, rank, texture, stacks, dtype, duration, timeleft = this:UnitDebuff("target", i) + effect, rank, texture, stacks, dtype, duration, timeleft = libdebuff:UnitDebuff("target", i) if texture and effect and duration then - this:AddEffect(UnitName("target"), UnitLevel("target"), effect) + libdebuff:AddEffect(UnitName("target"), UnitLevel("target"), effect) end end diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 32c82d82..d1ec64f4 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -627,12 +627,15 @@ pfUI:RegisterModule("nameplates", function () this.debuffs[j].icon:SetTexture(icon) this.debuffs[j].icon:SetTexCoord(.078, .92, .079, .937) - if libdebuff and name then + if name and libdebuff then this.debuffs[j].cd = this.debuffs[j].cd or CreateFrame("Model", nil, this.debuffs[j], "CooldownFrameTemplate") this.debuffs[j].cd.pfCooldownType = "ALL" - local start, duration, timeleft = libdebuff:GetDebuffInfo("target", name) - this.debuffs[j].cd:SetAlpha(0) - CooldownFrame_SetTimer(this.debuffs[j].cd, start, duration, 1) + + local name, rank, texture, stacks, dtype, duration, timeleft = libdebuff:UnitDebuff("target", i) + if duration and timeleft then + this.debuffs[j].cd:SetAlpha(0) + CooldownFrame_SetTimer(this.debuffs[i].cd, GetTime() + timeleft - duration, duration, 1) + end end k = k + 1