What is going on? You and your ex have a custody battle going on?
You have a lawsuit (civil or criminal?) against her current BF?
She has an Order of Protection against you?
Take all of this to the attorney handling your custody case. If you don't have an attorney, hire one.
You are in a dire situation I need you to call in for a consultation as there are some very specific but private questions to ask you as there are many issues here.
This is a general answer and does not address the specifics of your individual case. To give the specific answer you need our firm needs you to come in for a consultation.
If you are attending a madatory court appearance and your ex-girlfriend is also in court, your mere presence in court will not be a violation of your order of protection. Depending on the language in the order of protection any communication with her may be a violation. I would strongly suggest you hire an attorney.