@@ -106,40 +106,41 @@ local colors = {
106
106
},
107
107
}
108
108
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
117
114
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' )
121
117
end
118
+ end
119
+
120
+ local function customClassColors ()
121
+ if not _G .CUSTOM_CLASS_COLORS then return end
122
122
123
123
updateColors ()
124
+
124
125
_G .CUSTOM_CLASS_COLORS :RegisterCallback (updateColors )
125
126
126
127
return true
127
128
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
134
129
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 )
141
133
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
143
144
end
144
145
145
146
for debuffType , color in next , DebuffColors do
0 commit comments