A man who used to punch holes in the walls when drunk has been banned from contacting his former partner for five years.