Fixed that clearBuffs() doesn't terminate the buff, but only triggers onEnd() function. Because of that after buff duration ends, it triggers onEnd() function again. So you get two onEnds() calls overall.
Removed condition on alive unit, because otherwise after clearing the buffs of a unit on death, if you revive a unit, its buff stays, because it was dead, when you removed a buff. Otherwise have to clear buffs of dying unit before death, then condition could stay.
clearBuffs()
doesn't terminate the buff, but only triggersonEnd()
function. Because of that after buff duration ends, it triggersonEnd()
function again. So you get twoonEnds()
calls overall.