Skip to content

Commit 373c855

Browse files
committed
Fix automatic disabling of the addon for warriors
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.
1 parent a4e0d36 commit 373c855

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

FiveSecondRule.lua

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ do -- Private Scope
4040
FiveSecondRule:RegisterEvent("PLAYER_UNGHOST")
4141

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

4544
-- INITIALIZATION
4645
function Init()
4746
LoadOptions()
4847

48+
if (select(2, UnitClass("player")) == "WARRIOR") then
49+
-- Disable the addon for warriors, since there is no reliable power or life to track in order to show power ticks.
50+
DisableAddon()
51+
return
52+
else
53+
EnableAddon()
54+
end
55+
4956
TickBar:LoadSpells() -- LOCALIZATION
5057
FiveSecondRule:Refresh()
5158
end
@@ -56,10 +63,14 @@ do -- Private Scope
5663
end
5764

5865
function DisableAddon()
66+
StatusBar.statusbar:Hide()
67+
TickBar.tickbar:Hide()
5968
FiveSecondRule:SetScript("OnUpdate", nil)
60-
DisableAddOn(ADDON_NAME)
6169
end
62-
70+
71+
function EnableAddon()
72+
FiveSecondRule:SetScript("OnUpdate", function(self, sinceLastUpdate) onUpdate(sinceLastUpdate); end);
73+
end
6374

6475
function LoadOptions()
6576
FiveSecondRule_Options = FiveSecondRule_Options or AddonUtils:deepcopy(defaults)
@@ -79,25 +90,22 @@ do -- Private Scope
7990
end
8091

8192
function onEvent(self, event, arg1, ...)
82-
if (select(2, UnitClass("player")) == "WARRIOR") then
83-
-- Disable the addon for warriors, since there is no reliable power or life to track in order to show power ticks.
84-
print("FiveSecondRule addon has been disabled!")
85-
DisableAddon()
86-
return
87-
end
88-
8993
if event == "ADDON_LOADED" then
9094
if arg1 == ADDON_NAME then
9195
Init()
9296
end
9397
end
9498

99+
if not FiveSecondRule_Options.enabled then
100+
return
101+
end
102+
95103
if event == "PLAYER_ENTERING_WORLD" then
96104
savePlayerPower()
97105
end
98106

99-
if not FiveSecondRule_Options.enabled then
100-
return
107+
if event == "PLAYER_EQUIPMENT_CHANGED" then
108+
savePlayerPower()
101109
end
102110

103111
if event == "UNIT_SPELLCAST_SUCCEEDED" then
@@ -117,10 +125,6 @@ do -- Private Scope
117125
end
118126
end
119127
end
120-
121-
if event == "PLAYER_EQUIPMENT_CHANGED" then
122-
savePlayerPower()
123-
end
124128
end
125129

126130
function onUpdate(sinceLastUpdate)

FiveSecondRule.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Interface: 30403
22
## Title: Five Second Rule
33
## 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.
4-
## Version: 1.37
4+
## Version: 1.38
55
## DefaultState: enabled
66
## Author: CassiniEU @ Twitch.com
77
## SavedVariablesPerCharacter: FiveSecondRule_Options

FiveSecondRule.zip

15.4 KB
Binary file not shown.

FiveSecondRule_Classic.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Interface: 11500
22
## Title: Five Second Rule
33
## 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.
4-
## Version: 1.37
4+
## Version: 1.38
55
## DefaultState: enabled
66
## Author: CassiniEU @ Twitch.com
77
## SavedVariablesPerCharacter: FiveSecondRule_Options

0 commit comments

Comments
 (0)