The issue happens because you're modifying the player's effects list while it's still being cleared. When you run /effect clear, Minecraft is iterating over and removing all active effects. If you try to add a new one during that process (inside onEffectRemoved), it throws a ConcurrentModificationException. Instead of applying the new effect immediately inside onEffectRemoved, store it in a temporary list, and then apply it safely during the next tick (in a tick event). That way, the original clearing process finishes before you add anything new.
that is 1. In onEffectRemoved: just remember which effect to apply next. 2. In tick: apply the effect from the stored list.
More likely this prevents any conflict and works even when all effects are cleared at once
I hope it helped.