What you do is find out what the errors have in common. "Random" is not a cause, code doesn't behave that way. The code will do what you tell it to.
From what I can see you will get double messages whenever writing a team-message, and everyone will get it.
To fix this you either put a "return PLUGIN_HANDLED" after the team message is sent or you put the ColorChat() for the main chat inside an else-statement.
It is also possible another plugin is interfering but I would say that seems unlikely.