From f466d6fe816d22ca3b748492d7743d44d74822ac Mon Sep 17 00:00:00 2001 From: Ynazar1 Date: Mon, 29 Jul 2024 17:05:00 -0500 Subject: [PATCH] More API changes based on globe recommendations --- Libs/Broker_SmartBuff/Broker_SmartBuff.lua | 2 +- SmartBuff.lua | 38 +++++++++++++++------- SmartBuff.xml | 2 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Libs/Broker_SmartBuff/Broker_SmartBuff.lua b/Libs/Broker_SmartBuff/Broker_SmartBuff.lua index ae1b766..dbde713 100644 --- a/Libs/Broker_SmartBuff/Broker_SmartBuff.lua +++ b/Libs/Broker_SmartBuff/Broker_SmartBuff.lua @@ -26,7 +26,7 @@ F.LS = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("SmartBuff", { SMARTBUFF_OToggle(); SMARTBUFF_BROKER_SetIcon(); -- bug fix, credit: SunNova elseif (msg == "LeftButton" and IsAltKeyDown()) then - if (IsAddOnLoaded("SmartDebuff")) then + if (C_AddOns.IsAddOnLoaded("SmartDebuff")) then SMARTDEBUFF_ToggleSF(); end elseif (msg == "LeftButton") then diff --git a/SmartBuff.lua b/SmartBuff.lua index 6009da7..0e096aa 100644 --- a/SmartBuff.lua +++ b/SmartBuff.lua @@ -1789,7 +1789,7 @@ function SMARTBUFF_BuffUnit(unit, subgroup, mode, spell) SMARTBUFF_AddMsgD("Exclusive check on " .. spell .. ", current spell = " .. buffnS); end if (bUsable and cBuff.Type == SMARTBUFF_CONST_SELF and not SMARTBUFF_IsPlayer(unit)) then bUsable = false end - if (bUsable and not cBuff.Type == SMARTBUFF_CONST_TRACK and not SMARTBUFF_IsItem(cBuff.Type) and not IsUsableSpell(buffnS)) then bUsable = false end + if (bUsable and not cBuff.Type == SMARTBUFF_CONST_TRACK and not SMARTBUFF_IsItem(cBuff.Type) and not C_Spell.IsSpellUsable(buffnS)) then bUsable = false end if (bUsable and bs.SelfNot and SMARTBUFF_IsPlayer(unit)) then bUsable = false end if (bUsable and cBuff.Params == SG.CheckFishingPole and SMARTBUFF_IsFishingPoleEquiped()) then bUsable = false end @@ -1815,7 +1815,7 @@ function SMARTBUFF_BuffUnit(unit, subgroup, mode, spell) if (bUsable and not (cBuff.Type == SMARTBUFF_CONST_TRACK or SMARTBUFF_IsItem(cBuff.Type))) then -- check if you have enough mana/rage/energy to cast - local isUsable, notEnoughMana = IsUsableSpell(buffnS); + local isUsable, notEnoughMana = C_Spell.IsSpellUsable(buffnS); if (notEnoughMana) then bUsable = false; SMARTBUFF_AddMsgD("Buff " .. cBuff.BuffS .. ", not enough mana!"); @@ -2463,7 +2463,7 @@ function SMARTBUFF_doCast(unit, id, spellName, levels, type) end -- check if you have enough mana/energy/rage to cast - local isUsable, notEnoughMana = IsUsableSpell(spellName); + local isUsable, notEnoughMana = C_Spell.IsSpellUsable(spellName); if (notEnoughMana) then return 6; end @@ -2487,10 +2487,18 @@ end function UnitBuffByBuffName(target, buffname, filter) for i = 1, 40 do - name = UnitBuff(target, i, filter); + local AuraData = C_UnitAuras.GetAuraDataByIndex(target, i, filter); + if not AuraData then return end; + local name = AuraData.name; if not name then return end if name == buffname then - return UnitBuff(target, i, filter); + local icon = AuraData.icon; + local charges = AuraData.charges or 0; + local dispelName = AuraData.dispelName; + local duration = AuraData.duration; + local expirationTime = AuraData.expirationTime; + local source = AuraData.sourceUnit; + return name, icon, charges, dispelName, duration, expirationTime, source; end end end @@ -2700,10 +2708,14 @@ end function UnitAuraBySpellName(target, spellname, filter) for i = 1, 40 do - name = UnitAura(target, i, filter); + local AuraData = C_UnitAuras.GetAuraDataByIndex(target, i, filter); + if not AuraData then return end; + local name = AuraData.name; if not name then return end if name == spellname then - return UnitAura(target, i, filter); + local timeleft = AuraData.expirationTime; + local caster = AuraData.sourceUnit; + return name, timeleft, caster; end end end @@ -2712,7 +2724,7 @@ function SMARTBUFF_CheckBuff(unit, buffName, isMine) if (not unit or not buffName) then return false, 0; end - local buff, _, _, _, _, timeleft, caster = UnitAuraBySpellName(unit, buffName, "HELPFUL"); + local buff, timeleft, caster = UnitAuraBySpellName(unit, buffName, "HELPFUL"); if (buff) then SMARTBUFF_AddMsgD(UnitName(unit) .. " buff found: " .. buff, 0, 1, 0.5); if (buff == buffName) then @@ -2828,8 +2840,10 @@ function SMARTBUFF_IsDebuffTexture(unit, debufftex) local i = 1; local name, icon; -- name,rank,icon,count,type = UnitDebuff("unit", id or "name"[,"rank"]) - while (UnitDebuff(unit, i)) do - name, icon, _, _ = UnitDebuff(unit, i); + while (C_UnitAuras.GetDebuffDataByIndex(unit, i)) do + local DebuffInfo = C_UnitAuras.GetDebuffDataByIndex(unit, i); + name = DebuffInfo.name; + icon = DebuffInfo.icon; --SMARTBUFF_AddMsgD(i .. ". " .. name .. ", " .. icon); if (string.find(icon, debufftex)) then active = true; @@ -3114,7 +3128,7 @@ function SMARTBUFF_Options_Init(self) Cosmos_RegisterButton(SMARTBUFF_TITLE, SMARTBUFF_TITLE, SMARTBUFF_TITLE, imgSB, SMARTBUFF_OptionsFrame_Toggle); end - if (IsAddOnLoaded("Parrot")) then + if (C_AddOns.IsAddOnLoaded("Parrot")) then isParrot = true; end @@ -4439,7 +4453,7 @@ function SMARTBUFF_CheckMiniMapButton() end -- Update the FuBar icon - if (IsAddOnLoaded("FuBar") and IsAddOnLoaded("FuBar_SmartBuffFu") and SMARTBUFF_Fu_SetIcon ~= nil) then + if (C_AddOns.IsAddOnLoaded("FuBar") and C_AddOns.IsAddOnLoaded("FuBar_SmartBuffFu") and SMARTBUFF_Fu_SetIcon ~= nil) then SMARTBUFF_Fu_SetIcon(); end diff --git a/SmartBuff.xml b/SmartBuff.xml index 013790a..10f0f3a 100644 --- a/SmartBuff.xml +++ b/SmartBuff.xml @@ -375,7 +375,7 @@ if (button == "LeftButton" and IsAltKeyDown()) then - if (IsAddOnLoaded("SmartDebuff")) then + if (C_AddOns.IsAddOnLoaded("SmartDebuff")) then SMARTDEBUFF_ToggleSF(); end elseif (button == "LeftButton") then