Skip to content

Commit

Permalink
Fix addon disablement for non-Monks
Browse files Browse the repository at this point in the history
  • Loading branch information
ntowle committed Nov 14, 2023
1 parent dcddc39 commit 0b3e83d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ globals = {
"ChatFrame_AddMessageEventFilter",
"CreateFrame",
"MuteSoundFile",
"UnitClass",
"UnitClassBase",
"UnitName",
"WorldFrame"
}
12 changes: 7 additions & 5 deletions SilenceBanLu.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
local addonName = ...

-- globals
local CreateFrame, C_ChatBubbles, UnitClass, C_AddOns, MuteSoundFile, ChatFrame_AddMessageEventFilter, WorldFrame = CreateFrame, C_ChatBubbles, UnitClass, C_AddOns, MuteSoundFile, ChatFrame_AddMessageEventFilter, WorldFrame
local CreateFrame, C_ChatBubbles, UnitClassBase, C_AddOns, UnitName, MuteSoundFile, ChatFrame_AddMessageEventFilter, WorldFrame = CreateFrame, C_ChatBubbles, UnitClassBase, C_AddOns, UnitName, MuteSoundFile, ChatFrame_AddMessageEventFilter, WorldFrame

-- disable the addon for non-Monk players
if select(2, UnitClass('player')) ~= "MONK" then
C_AddOns.DisableAddOn("SilenceBanLu")
if UnitClassBase("player") ~= "MONK" then
C_AddOns.DisableAddOn(addonName, UnitName("player"))
return
end

Expand Down Expand Up @@ -34,7 +36,7 @@ local banLuMessages = {}
-- returns the text contained within a currently displayed chat bubble
local function getChatBubbleText(chatBubble)
-- get chat bubble frame
local chatBubbleFrame = select(1, chatBubble:GetChildren())
local chatBubbleFrame = chatBubble:GetChildren()
for i = 1, chatBubbleFrame:GetNumRegions() do
local region = select(i, chatBubbleFrame:GetRegions())
-- only the bubble region with text will have ObjectType == FontString
Expand Down Expand Up @@ -125,4 +127,4 @@ end
ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", notBanLuFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", notBanLuFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", notBanLuFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_MONSTER_YELL", notBanLuFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_MONSTER_YELL", notBanLuFilter)

0 comments on commit 0b3e83d

Please sign in to comment.