diff --git a/Core.lua b/Core.lua index ce84b7fb..6522c2dd 100644 --- a/Core.lua +++ b/Core.lua @@ -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 diff --git a/Core/Caching.lua b/Core/Caching.lua index c709431a..d01f1276 100644 --- a/Core/Caching.lua +++ b/Core/Caching.lua @@ -6,7 +6,6 @@ local Caching = {} local IsInitializing = true local itemsPrimed = 0 local itemsToPrime = 100 -local playerClass -- Upvalues local UnitFactionGroup = UnitFactionGroup @@ -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 diff --git a/Core/EventHandlers.lua b/Core/EventHandlers.lua index 6c2e8872..be42839e 100644 --- a/Core/EventHandlers.lua +++ b/Core/EventHandlers.lua @@ -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 diff --git a/Core/GUI/MainWindow.lua b/Core/GUI/MainWindow.lua index 1d093a6c..5fa8116d 100644 --- a/Core/GUI/MainWindow.lua +++ b/Core/GUI/MainWindow.lua @@ -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