Skip to content

Commit

Permalink
fix: Issue where mythic+ dungeons do not register on startup due to d…
Browse files Browse the repository at this point in the history
…ata not being availlable
  • Loading branch information
peti446 committed Dec 6, 2023
1 parent 8ecf6e0 commit 40df3e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions GobalEvents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ function SwitchSwitch:SWITCHSWITCH_BOSS_DETECTED(event_name, instanceID, difficu
self:ToggleSuggestionFrame(suggestedProfileId)
end
end
end

function SwitchSwitch:CHALLENGE_MODE_MAPS_UPDATE(_event_name)
self:DebugPrint("CHALLENGE_MODE_MAPS_UPDATE")
self:RegisterMyticPlusDungeonsDetection()
end
20 changes: 14 additions & 6 deletions Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function SwitchSwitch:OnInitialize()
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
self:RegisterEvent("TRAIT_CONFIG_UPDATED")
self:RegisterEvent("CHALLENGE_MODE_MAPS_UPDATE")

-- Set up Settings for profiles settings
local aceOptionTable = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
Expand All @@ -70,6 +71,16 @@ function SwitchSwitch:OnInitialize()
self:DebugPrint("Addon Initialized")
end

function SwitchSwitch:RegisterMyticPlusDungeonsDetection()
local detectionModule = self:GetModule("BossDetection")
for _journalID, instanceID in pairs(SwitchSwitch.MythicPlusDungeons[self:GetCurrentMythicPlusSeason()]) do
detectionModule:RegisterInstance(instanceID, {})
if(self:GetMythicPlusProfileSuggestion(instanceID) ~= nil) then
detectionModule:SetDetectionForInstanceEnabled(instanceID, self.PreMythicPlusDificulty, true)
end
end
end

function SwitchSwitch:OnEnable()
self:DebugPrint("Addon Enabling")

Expand All @@ -92,6 +103,7 @@ function SwitchSwitch:OnEnable()
self:RegisterMessage("SWITCHSWITCH_INSTANCE_TYPE_DETECTED")
self:EnableModule("BossDetection")
local detectionModule = self:GetModule("BossDetection")
self:DebugPrint("Starting to register instances")
for expansion, data in pairs(SwitchSwitch.InstancesBossData) do
for contentType, contentData in pairs(data) do
for jurnalID, InstanceData in pairs(contentData) do
Expand All @@ -109,12 +121,8 @@ function SwitchSwitch:OnEnable()
end
end

for _journalID, instanceID in pairs(SwitchSwitch.MythicPlusDungeons[self:GetCurrentMythicPlusSeason()]) do
detectionModule:RegisterInstance(instanceID, {})
if(self:GetMythicPlusProfileSuggestion(instanceID) ~= nil) then
detectionModule:SetDetectionForInstanceEnabled(instanceID, self.PreMythicPlusDificulty, true)
end
end
self:RegisterMyticPlusDungeonsDetection()

-- Enable boss detection for pvp and arenas
local data = SwitchSwitch:GetProfilesSuggestionInstanceData("pvp")
SwitchSwitch:GetModule("BossDetection"):SetDetectingInstanceTypeEnabled("pvp", data["all"] ~= nil)
Expand Down
2 changes: 1 addition & 1 deletion SwitchSwitch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ function SwitchSwitch:GetCurrentMythicPlusSeason()
currentSeasonID = SwitchSwitch.DefaultMythicPlusSeason
end

return currentSeasonID
return currentSeasonID or -1
end

function SwitchSwitch:RefreshCurrentConfigID()
Expand Down

0 comments on commit 40df3e2

Please sign in to comment.