Skip to content

Commit

Permalink
Merge pull request #658 from WowRarity/class-filter-fix
Browse files Browse the repository at this point in the history
Prevent alerts from triggering for class-filtered items
  • Loading branch information
rdw-software authored Oct 6, 2023
2 parents 2d0d738 + c778a4b commit c9ccb98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
7 changes: 2 additions & 5 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,8 @@ function R:IsAttemptAllowed(item)
end

-- Check disabled classes
local playerClass = Rarity.Caching:GetPlayerClass() -- Why is this cached in the first place?
if not playerClass then
Rarity.Caching:SetPlayerClass(select(2, UnitClass("player")))
end
if item.disableForClass and type(item.disableForClass) == "table" and item.disableForClass[playerClass] == true then
local playerClass = select(2, UnitClass("player"))
if item.disableForClass and item.disableForClass[playerClass] then
Rarity:Debug(format("Attempts for item %s are disallowed (disabled for class %s)", item.name, playerClass))
return false
end
Expand Down
9 changes: 0 additions & 9 deletions Core/Caching.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local Caching = {}
local IsInitializing = true
local itemsPrimed = 0
local itemsToPrime = 100
local playerClass
-- Upvalues
local UnitFactionGroup = UnitFactionGroup

Expand Down Expand Up @@ -58,13 +57,5 @@ function Caching:GetItemsToPrime()
return itemsToPrime
end

function Caching:GetPlayerClass()
return playerClass
end

function Caching:SetPlayerClass(class)
playerClass = class
end

Rarity.Caching = Caching
return Caching
6 changes: 6 additions & 0 deletions Core/EventHandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,12 @@ function R:OnItemFound(itemId, item)
return
end

local playerClass = select(2, UnitClass("player"))
if item.disableForClass and item.disableForClass[playerClass] then
Rarity:Debug(format("Ignoring OnItemFound trigger for item %s (disabled for class %s)", item.name, playerClass))
return
end

self:Debug("FOUND ITEM %d!", itemId)
if item.attempts == nil then
item.attempts = 1
Expand Down
10 changes: 2 additions & 8 deletions Core/GUI/MainWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,8 @@ local function addGroup(group, requiresGroup)
)
then
local classGood = true
if not Rarity.Caching:GetPlayerClass() then
Rarity.Caching:SetPlayerClass(select(2, UnitClass("player")))
end
if
v.disableForClass
and type(v.disableForClass == "table")
and v.disableForClass[Rarity.Caching:GetPlayerClass()] == true
then
local playerClass = select(2, UnitClass("player"))
if v.disableForClass and v.disableForClass[playerClass] then
classGood = false
end

Expand Down

0 comments on commit c9ccb98

Please sign in to comment.