Add 1s timer to remove buffs
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
local addonname, shared = ...
|
||||
---@cast addonname string
|
||||
|
||||
---@class shared
|
||||
---@field timer number?
|
||||
shared = { timer = nil }
|
||||
|
||||
---@class DechickenatorData
|
||||
---@field alerts table<string, Alert>
|
||||
|
||||
@@ -12,7 +16,7 @@ local addonname, shared = ...
|
||||
--/dechicken a:Greater Blessing of Kings;R;e:spit;m:cuntfucker
|
||||
--/dechicken a:Greater Blessing of Kings;R;e:spit;m:cuntfucker
|
||||
--/dechicken a:Greater Blessing of Kings;R;m:cuntfucker
|
||||
--/dechicken a:Greater Blessing of Kings;R;e:laugh
|
||||
--/dechicken a:Turkey Feathers;R;e:laugh
|
||||
---@class Alert
|
||||
---@field message string?
|
||||
---@field channel string?
|
||||
@@ -25,6 +29,24 @@ local addonname, shared = ...
|
||||
if not Dechickenator_Data then Dechickenator_Data = {} end
|
||||
if not Dechickenator_Data.alerts then Dechickenator_Data.alerts = {} end
|
||||
local function init()
|
||||
local function RemoveBuff(buff)
|
||||
if UnitAffectingCombat("player") then return end
|
||||
CancelUnitBuff("player", buff)
|
||||
end
|
||||
local function RemoveBuffs()
|
||||
if UnitAffectingCombat("player") then return end
|
||||
for buff, enabled in pairs(Dechickenator_Data.alerts) do
|
||||
if enabled then
|
||||
RemoveBuff(buff)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not shared.timer then
|
||||
shared.timer = C_Timer.NewTicker(1, function()
|
||||
RemoveBuffs()
|
||||
end)
|
||||
end
|
||||
|
||||
local cleuFrame = CreateFrame("Frame")
|
||||
cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
cleuFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
@@ -50,7 +72,7 @@ local function init()
|
||||
DoEmote(Dechickenator_Data.alerts[spellName].emote, source)
|
||||
end
|
||||
if Dechickenator_Data.alerts[spellName].remove then
|
||||
CancelUnitBuff("player", spellName)
|
||||
RemoveBuff(spellName)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user