From 6e2b18bca530ae6f462e8411e44827abc09b1b10 Mon Sep 17 00:00:00 2001 From: gnwl Date: Fri, 3 Nov 2023 05:16:25 -0500 Subject: [PATCH] update announcing adjustments --remove ChatFrame_OnEvent hook --register CHAT_MSG_CHANNEL events --move the CHAT_MSG_CHANNEL hanlder into the OnEvent script --modify the CHAT_MSG_CHANNEL handler to avoid unnecessary actions --- Core/AtlasLoot.lua | 49 +++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/Core/AtlasLoot.lua b/Core/AtlasLoot.lua index 0b14f7f..9eeae7d 100644 --- a/Core/AtlasLoot.lua +++ b/Core/AtlasLoot.lua @@ -3830,26 +3830,31 @@ local remoteversion = tonumber(AtlasLoot_updateavailable) or 0 local loginchannels = { "BATTLEGROUND", "RAID", "GUILD" } local groupchannels = { "BATTLEGROUND", "RAID" } -AtlasLoot_updater_ChatFrame_OnEvent = ChatFrame_OnEvent AtlasLoot_updater = CreateFrame("Frame") AtlasLoot_updater:RegisterEvent("CHAT_MSG_ADDON") +AtlasLoot_updater:RegisterEvent("CHAT_MSG_CHANNEL") AtlasLoot_updater:RegisterEvent("PLAYER_ENTERING_WORLD") AtlasLoot_updater:RegisterEvent("PARTY_MEMBERS_CHANGED") -function ChatFrame_OnEvent(event) +AtlasLoot_updater:SetScript("OnEvent", function() + if event == "CHAT_MSG_ADDON" and arg1 == "AtlasLoot" then + local v, remoteversion = AtlasLoot_strsplit(":", arg2) + local remoteversion = tonumber(remoteversion) + if remoteversion >= 40000 then remoteversion = 0 end --Block for people using some version from another version of WoW. + if v == "VERSION" and remoteversion then + if remoteversion > localversion then + AtlasLoot_updateavailable = remoteversion + if not alreadyshown then + DEFAULT_CHAT_FRAME:AddMessage("|cffbe5eff[AtlasLoot]|r New version available! https://github.com/Lexiebean/AtlasLoot/") + alreadyshown = true + end + end + end + end if event == "CHAT_MSG_CHANNEL" then - - local type = strsub(event, 10) - local source = strsub(type,1,1) - if type == "CHANNEL" and arg4 then - _,_,source = string.find(arg4,"(%d+)%.") - end - - if source then - _,name = GetChannelName(source) - end - + local _,_,source = string.find(arg4,"(%d+)%.") + local _,name = GetChannelName(source) if name == "LFT" then local msg, v, remoteversion = AtlasLoot_strsplit(":", arg1) if msg == "Atlasloot" then @@ -3867,24 +3872,6 @@ function ChatFrame_OnEvent(event) end end end - AtlasLoot_updater_ChatFrame_OnEvent(event); -end - -AtlasLoot_updater:SetScript("OnEvent", function() - if event == "CHAT_MSG_ADDON" and arg1 == "AtlasLoot" then - local v, remoteversion = AtlasLoot_strsplit(":", arg2) - local remoteversion = tonumber(remoteversion) - if remoteversion >= 40000 then remoteversion = 0 end --Block for people using some version from another version of WoW. - if v == "VERSION" and remoteversion then - if remoteversion > localversion then - AtlasLoot_updateavailable = remoteversion - if not alreadyshown then - DEFAULT_CHAT_FRAME:AddMessage("|cffbe5eff[AtlasLoot]|r New version available! https://github.com/Lexiebean/AtlasLoot/") - alreadyshown = true - end - end - end - end if event == "PARTY_MEMBERS_CHANGED" then local groupsize = GetNumRaidMembers() > 0 and GetNumRaidMembers() or GetNumPartyMembers() > 0 and GetNumPartyMembers() or 0