A town’s troubled eyesore block of flats is set to be demolished to make way for new apartments following a bitter long, drawn-out court battle.