Skip to content

Commit

Permalink
Fix automatic disabling of the addon for warriors
Browse files Browse the repository at this point in the history
The previous implementation would disable the addon completely for all classes. Now the update function is merely disabled and the bars hidden.

Refactored and cleaned up initiation of the addon.

Bump version to 1.38.
  • Loading branch information
smp4903 committed Jan 19, 2024
1 parent a4e0d36 commit 373c855
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions FiveSecondRule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ do -- Private Scope
FiveSecondRule:RegisterEvent("PLAYER_UNGHOST")

FiveSecondRule:SetScript("OnEvent", function(self, event, arg1, ...) onEvent(self, event, arg1, ...) end);
FiveSecondRule:SetScript("OnUpdate", function(self, sinceLastUpdate) onUpdate(sinceLastUpdate); end);

-- INITIALIZATION
function Init()
LoadOptions()

if (select(2, UnitClass("player")) == "WARRIOR") then
-- Disable the addon for warriors, since there is no reliable power or life to track in order to show power ticks.
DisableAddon()
return
else
EnableAddon()
end

TickBar:LoadSpells() -- LOCALIZATION
FiveSecondRule:Refresh()
end
Expand All @@ -56,10 +63,14 @@ do -- Private Scope
end

function DisableAddon()
StatusBar.statusbar:Hide()
TickBar.tickbar:Hide()
FiveSecondRule:SetScript("OnUpdate", nil)
DisableAddOn(ADDON_NAME)
end


function EnableAddon()
FiveSecondRule:SetScript("OnUpdate", function(self, sinceLastUpdate) onUpdate(sinceLastUpdate); end);
end

function LoadOptions()
FiveSecondRule_Options = FiveSecondRule_Options or AddonUtils:deepcopy(defaults)
Expand All @@ -79,25 +90,22 @@ do -- Private Scope
end

function onEvent(self, event, arg1, ...)
if (select(2, UnitClass("player")) == "WARRIOR") then
-- Disable the addon for warriors, since there is no reliable power or life to track in order to show power ticks.
print("FiveSecondRule addon has been disabled!")
DisableAddon()
return
end

if event == "ADDON_LOADED" then
if arg1 == ADDON_NAME then
Init()
end
end

if not FiveSecondRule_Options.enabled then
return
end

if event == "PLAYER_ENTERING_WORLD" then
savePlayerPower()
end

if not FiveSecondRule_Options.enabled then
return
if event == "PLAYER_EQUIPMENT_CHANGED" then
savePlayerPower()
end

if event == "UNIT_SPELLCAST_SUCCEEDED" then
Expand All @@ -117,10 +125,6 @@ do -- Private Scope
end
end
end

if event == "PLAYER_EQUIPMENT_CHANGED" then
savePlayerPower()
end
end

function onUpdate(sinceLastUpdate)
Expand Down
2 changes: 1 addition & 1 deletion FiveSecondRule.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 30403
## Title: Five Second Rule
## Notes: Track the "5-second-rule" (5SR or FSR) which refers to the cooldown of five seconds after spending mana before spirit-based regen resumes.
## Version: 1.37
## Version: 1.38
## DefaultState: enabled
## Author: CassiniEU @ Twitch.com
## SavedVariablesPerCharacter: FiveSecondRule_Options
Expand Down
Binary file added FiveSecondRule.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion FiveSecondRule_Classic.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 11500
## Title: Five Second Rule
## Notes: Track the "5-second-rule" (5SR or FSR) which refers to the cooldown of five seconds after spending mana before spirit-based regen resumes.
## Version: 1.37
## Version: 1.38
## DefaultState: enabled
## Author: CassiniEU @ Twitch.com
## SavedVariablesPerCharacter: FiveSecondRule_Options
Expand Down

0 comments on commit 373c855

Please sign in to comment.