diff --git a/Dechickenator.lua b/Dechickenator.lua index 6e0d26f..38420ac 100644 --- a/Dechickenator.lua +++ b/Dechickenator.lua @@ -1,6 +1,10 @@ local addonname, shared = ... ---@cast addonname string +---@class shared +---@field timer number? +shared = { timer = nil } + ---@class DechickenatorData ---@field blacklistedBuffs table @@ -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 diff --git a/Dechickenator.zip b/Dechickenator.zip index e462483..36d2ba6 100644 Binary files a/Dechickenator.zip and b/Dechickenator.zip differ