Skip to content

Commit

Permalink
More API changes based on globe recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
ynazar1 committed Jul 29, 2024
1 parent 8853404 commit f466d6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Libs/Broker_SmartBuff/Broker_SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 26 additions & 12 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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!");
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion SmartBuff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
</OnLoad>
<OnClick>
if (button == "LeftButton" and IsAltKeyDown()) then
if (IsAddOnLoaded("SmartDebuff")) then
if (C_AddOns.IsAddOnLoaded("SmartDebuff")) then
SMARTDEBUFF_ToggleSF();
end
elseif (button == "LeftButton") then
Expand Down

0 comments on commit f466d6f

Please sign in to comment.