@@ -106,40 +106,41 @@ local colors = {
106106 },
107107}
108108
109- -- We do this because people edit the vars directly, and changing the default
110- -- globals makes SPICE FLOW!
111- local function customClassColors ()
112- if (_G .CUSTOM_CLASS_COLORS ) then
113- local function updateColors ()
114- for classToken , color in next , _G .CUSTOM_CLASS_COLORS do
115- colors .class [classToken ] = oUF :CreateColor (color .r , color .g , color .b )
116- end
109+ do -- We do this because people edit the vars directly, and changing the default globals makes SPICE FLOW!
110+ local function updateColors ()
111+ for classToken , color in next , _G .CUSTOM_CLASS_COLORS do
112+ colors .class [classToken ] = oUF :CreateColor (color .r , color .g , color .b )
113+ end
117114
118- for _ , obj in next , oUF .objects do
119- obj :UpdateAllElements (' CUSTOM_CLASS_COLORS' )
120- end
115+ for _ , obj in next , oUF .objects do
116+ obj :UpdateAllElements (' CUSTOM_CLASS_COLORS' )
121117 end
118+ end
119+
120+ local function customClassColors ()
121+ if not _G .CUSTOM_CLASS_COLORS then return end
122122
123123 updateColors ()
124+
124125 _G .CUSTOM_CLASS_COLORS :RegisterCallback (updateColors )
125126
126127 return true
127128 end
128- end
129-
130- if (not customClassColors ()) then
131- for classToken , color in next , _G .RAID_CLASS_COLORS do
132- colors .class [classToken ] = oUF :CreateColor (color .r , color .g , color .b )
133- end
134129
135- local eventHandler = CreateFrame (' Frame' )
136- eventHandler :RegisterEvent (' ADDON_LOADED' )
137- eventHandler :SetScript (' OnEvent' , function (self )
138- if (customClassColors ()) then
139- self :UnregisterEvent (' ADDON_LOADED' )
140- self :SetScript (' OnEvent' , nil )
130+ if not customClassColors () then
131+ for classToken , color in next , _G .RAID_CLASS_COLORS do
132+ colors .class [classToken ] = oUF :CreateColor (color .r , color .g , color .b )
141133 end
142- end )
134+
135+ local eventHandler = CreateFrame (' Frame' )
136+ eventHandler :RegisterEvent (' ADDON_LOADED' )
137+ eventHandler :RegisterEvent (' PLAYER_ENTERING_WORLD' )
138+ eventHandler :SetScript (' OnEvent' , function (frame )
139+ if customClassColors () then
140+ frame :UnregisterAllEvents ()
141+ end
142+ end )
143+ end
143144end
144145
145146for debuffType , color in next , DebuffColors do
0 commit comments