Afenar / AfenarUI

World of Warcraft User Interface
https://wago.io/AfenarUI
487 stars 189 forks source link

Mage Barier Fix(UnitBuff function deprecation) #119

Open BerkOzdilek opened 2 months ago

BerkOzdilek commented 2 months ago

Hey, first of all thanks for sharing your WA, really appreciated. I fixed some of the issues caused by the latest WoW API changes and wanted to share with you so that you can update if you wish. I cant open a PR so intead Im posting it here.

With 11.0.2, some of the WoW APIs are deprecated(here). UnitBuff function which was deprecated and replaced by C_UnitAuras.GetBuffDataByIndex function. This is used by the all of the mage barriers weak auras to show how many absorb left. (I find it super cool) I replaced that function with the new one according to this doc

Sharing the new custom text function below

function()
    local abbr = ' '

    for i =1, 40 do
        local aura= C_UnitAuras.GetBuffDataByIndex("player",i)
        if aura and aura.spellId == 235450
        then
            local absb = aura.points[1]
            absb = absb / 1000
            abbr = string.format("%.1fk", absb)
        end
    end

    return abbr
end

The main diference is: C_UnitAuras.GetBuffDataByIndex function returns a AuraData object. The points field is an array and consist the absorb amount as the first element.