From 7d5700972f205c56dff50f3a049a4596ebfd0674 Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 15 Jul 2022 13:30:13 +0200 Subject: [PATCH] social-colors: only parse chat if text is set --- mods/social-colors.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mods/social-colors.lua b/mods/social-colors.lua index fcba033..c9d9ceb 100644 --- a/mods/social-colors.lua +++ b/mods/social-colors.lua @@ -23,17 +23,19 @@ module.enable = function(self) if not _G["ChatFrame"..i].HookAddMessageColor and not Prat then _G["ChatFrame"..i].HookAddMessageColor = _G["ChatFrame"..i].AddMessage _G["ChatFrame"..i].AddMessage = function(frame, text, a1, a2, a3, a4, a5) - for name in gfind(text, "|Hplayer:(.-)|h") do - local real, _ = strsplit(":", name) - local color = "|cffaaaaaa" - local class = GetUnitData(real) + if text then + for name in gfind(text, "|Hplayer:(.-)|h") do + local real, _ = strsplit(":", name) + local color = "|cffaaaaaa" + local class = GetUnitData(real) - if class and class ~= UNKNOWN then - color = rgbhex(RAID_CLASS_COLORS[class]) + if class and class ~= UNKNOWN then + color = rgbhex(RAID_CLASS_COLORS[class]) + end + + text = string.gsub(text, "|Hplayer:"..name.."|h%["..real.."%]|h(.-:-)", + "|r["..color.."|Hplayer:"..name.."|h" .. color .. real .. "|h|r".."]|r".."%1") end - - text = string.gsub(text, "|Hplayer:"..name.."|h%["..real.."%]|h(.-:-)", - "|r["..color.."|Hplayer:"..name.."|h" .. color .. real .. "|h|r".."]|r".."%1") end _G["ChatFrame"..i].HookAddMessageColor(frame, text, a1, a2, a3, a4, a5)