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 blacklistedBuffs table<string, boolean>
|
||||
|
||||
@@ -8,6 +12,25 @@ if not Dechickenator_Data then Dechickenator_Data = {} end
|
||||
if not Dechickenator_Data.blacklistedBuffs then Dechickenator_Data.blacklistedBuffs = {} end
|
||||
if not Dechickenator_Data.message then Dechickenator_Data.message = "Индивидуум %s хочет поделиться своим истинным обликом" 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.blacklistedBuffs) 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, ...)
|
||||
@@ -19,7 +42,7 @@ local function init()
|
||||
if not Dechickenator_Data.blacklistedBuffs[spellName] then return end
|
||||
local source = CLEUParser.GetSourceName(...)
|
||||
local msg = string.format(Dechickenator_Data.message, tostring(source))
|
||||
CancelUnitBuff("player", spellName)
|
||||
RemoveBuff(spellName)
|
||||
SendChatMessage(msg, "EMOTE")
|
||||
DoEmote("spit", source)
|
||||
end
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user