--COMBAT_LOG_EVENT_UNFILTERED GROUP_ROSTER_UPDATE
function(allstates, e, ...)
    local aura_env = aura_env
    local restoreState = function(name, state, dur, pclass)
        if allstates[name .. state] then
            allstates[name .. state] = {
                -- Playername .. spellname
                show = true,
                changed = true,
                index = name,
                resort = true,
                name = aura_env.classColor(pclass) .. name .. "\124r",
                icon = GetSpellTexture(state),
                progressType = "static",
                value = dur,
                total = dur,
            }
            return true
        end
    end
    if e == "COMBAT_LOG_EVENT_UNFILTERED" then
        local se = select(2, ...)
        if se == "SPELL_CAST_SUCCESS" then
            local name = select(5, ...)
            local spellID = select(12, ...)
            if aura_env.classSpells[select(3, UnitClass(name))] and aura_env.classSpells[select(3, UnitClass(name))][spellID] then -- Player should probably be tracked
                --print(name, spell)
                --DevTools_Dump(allstates)
                if allstates[name .. select(1, GetSpellInfo(spellID))] then
                    --print("YEET")
                    local pclass = select(3, UnitClass(name))
                    local dur = aura_env.classSpells[select(3, UnitClass(name))][spellID]
                    allstates[name .. select(1, GetSpellInfo(spellID))] = {
                        show = true,
                        changed = true,
                        index = name,
                        resort = true,
                        name = aura_env.classColor(select(3, UnitClass(name))) .. name .. "\124r",
                        icon = GetSpellTexture(spellID),
                        progressType = "timed",
                        expirationTime = GetTime() + aura_env.classSpells[select(3, UnitClass(name))][spellID],
                        duration = dur,
                    ticker = C_Timer.After(dur - dur / 3, function() restoreState(name, spellID, dur, pclass) end)}
                    return true
                end
            end
        end
    elseif e == "GROUP_ROSTER_UPDATE" then
        aura_env.groupMembers = {}
        for k, v in pairs(allstates) do
            v.show = false
            v.changed = true
        end
        for i = 1, GetNumGroupMembers() do
            if IsInRaid() == true then
                aura_env.groupMembers[UnitName("raid" .. i)] = select(3, UnitClass("raid" .. i))
            end
        end
        for k, v in pairs(aura_env.groupMembers) do
            if aura_env.classSpells[v] then
                for k2, v2 in pairs(aura_env.classSpells[v]) do
                    allstates[k .. select(1, GetSpellInfo(k2))] = {
                        -- Playername .. spellname
                        show = true,
                        changed = true,
                        index = k,
                        class = v,
                        resort = true,
                        name = aura_env.classColor(v) .. k .. "\124r",
                        icon = GetSpellTexture(k2),
                        progressType = "static",
                        value = v2,
                        total = v2,
                    }
                end
            end
        end
    end
    return true
end

--INIT
aura_env.groupMembers = {}
aura_env.classSpells = {
    -- Form [SpellID] = spellcooldown,
    [2] = {-- Paladin
        [31821] = 180,
    },
    [11] = {--Druid
        
    },
    [5] = {-- Priest
        
    },
    [7] = {-- Shaman
        
    },
    [10] = {-- Monk
        
    },
}
aura_env.classColor = function(class)
    if class == 6 then return "\124cFFC41F3B" elseif
    class == 12 then return "\124cFFA330C9" elseif
    class == 11 then return "\124cFFFF7D0A" elseif
    class == 3 then return "\124cFFABD473" elseif
    class == 8 then return "\124cFF40C7EB" elseif
    class == 10 then return "\124cFF00FF96" elseif
    class == 2 then return "\124cFFF58CBA" elseif
    class == 5 then return "\124cFFFFFFFF" elseif
    class == 4 then return "\124cFFFFF569" elseif
    class == 7 then return "\124cFF0070DE" elseif
    class == 9 then return "\124cFF8787ED" elseif
    class == 1 then return "\124cFFC79C6E" else
    return "\124cFF000000" end
end
