Skip to content

Commit a26efb6

Browse files
committed
Add compat UnitAura method.
1 parent 7147162 commit a26efb6

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

LibMagicUtil-1.0/LibMagicUtil-1.0.lua

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After embedding you will be able to use the following methods:
2424
]]
2525

2626
local MAJOR = "LibMagicUtil-1.0"
27-
local MINOR = 2024081802
27+
local MINOR = 2025053101
2828

2929
local lib = LibStub:NewLibrary(MAJOR, MINOR)
3030
local media = LibStub("LibSharedMedia-3.0")
@@ -36,7 +36,7 @@ local embeddables = {
3636
"GetConfigTemplate", "_GetColorOpt", "_SetColorOpt", "_SetOption", "_GetOption",
3737
"_HideOption", "_DisableTiling", "FixBackdrop", "_SetBackgroundOption",
3838
"InterfaceOptions_AddCategory", "InterfaceOptionsFrame_OpenToCategory", "Dump",
39-
"GetSpellInfo"
39+
"GetSpellInfo", "UnitAura"
4040
}
4141

4242
lib.optionTemplates = lib.optionTemplates or {}
@@ -56,6 +56,33 @@ lib.GetSpellInfo = GetSpellInfo or function(id)
5656
end
5757
end
5858

59+
lib.UnitAura = UnitAura or function(unit, index, filter)
60+
local aura = C_UnitAuras and C_UnitAuras.GetAuraDataByIndex(unit, index)
61+
if not aura then return nil end
62+
63+
-- Map new API fields to old UnitAura return values
64+
local name = aura.name
65+
local icon = aura.icon
66+
local count = aura.applications or 1
67+
local debuffType = aura.dispelName
68+
local duration = aura.duration
69+
local expirationTime = aura.expirationTime
70+
local caster = aura.sourceUnit
71+
local isStealable = aura.isStealable
72+
local nameplateShowPersonal = aura.nameplateShowPersonal
73+
local spellId = aura.spellId
74+
local canApplyAura = aura.canApplyAura
75+
local isBossDebuff = aura.isBossDebuff
76+
local isCastByPlayer = aura.isFromPlayerOrPlayerPet
77+
local nameplateShowAll = aura.nameplateShowAll
78+
local timeMod = aura.timeMod or 1
79+
local value1, value2, value3 = aura.points or 0, nil, nil
80+
81+
return name, icon, count, debuffType, duration, expirationTime, caster,
82+
isStealable, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff,
83+
isCastByPlayer, nameplateShowAll, timeMod, value1, value2, value3
84+
end
85+
5986
function lib:GetConfigTemplate(config, get, set)
6087
assert(self ~= lib, "GetConfigTemplate can only be called when embedded.")
6188
assert(optionTemplates[config] ~= nil, "Unknown config template: "..config)

0 commit comments

Comments
 (0)