I have the following problem
$$ \begin{align}\begin{cases} u_{tt} - 4 u_{xx} =0 & t > 0 , 0 < x < 3\pi \\ u(0,t) = -\pi, u(3\pi, t) = 2\pi & t> 0 \\ u(x,0) = 0 , u_{t}(x,0) = 0 & 0 < x < 3\pi \end{cases} \end{align} $$
In fact I do not know how to fix with $u_{t}(x,0) = 0$
For the homogeneous wave equation with non-homogeneous boundary conditions like below
$$ \begin{align}\begin{cases} u_{tt} - c^{2} u_{xx} =0 & t > 0 , 0 < x < L \\ u(0,t) = \phi(t), u(L, t) = \psi(t) & t> 0 \\ u(x,0) = f(x) , u_{t}(x,0) = g(x) & 0 < x < L \end{cases} \end{align} $$
you introduce a reference function $r(x,t)$ such that $u(x,t) = v(x,t) +r(x,t)$ where $v(x,t)$ is a function satisifying the homogeneous solution and $r(x,t)$ satisfies the nonhomogeneous boundary conditions.
To do this we can make $r(x,t)$ the following function
$$ r(x,t) = \frac{x}{L}\left[ \psi(t) - \phi(t) \right] + \phi(t)$$
in this case, your $r(x,t)$ isn't time-dependent and we can write is as
$$ r(x) = \frac{x}{3\pi}\left[ 2\pi - (-\pi) \right] - \pi = \frac{3\pi x}{3\pi} - \pi = x - \pi$$
then your $v(x,t)$ is the homogeneous solution as usual which is
$$ v(x,t) = \sum_{n=1}^{\infty} \bigg( A_{n} \sin(\frac{n \pi x}{3\pi})\cos(\frac{2 n\pi t}{3\pi} )+ B_{n} \sin(\frac{n \pi x}{3\pi}) \sin(\frac{2 n \pi t}{3\pi})\bigg) $$
which can be reduced as
$$ v(x,t) = \sum_{n=1}^{\infty} \bigg( A_{n} \sin(\frac{n x}{3})\cos(\frac{2 n t}{3}) + B_{n} \sin(\frac{n x}{3}) \sin(\frac{2 n t}{3})\bigg) $$
$$ v(x,t) = \sum_{n=1}^{\infty} \bigg( A_{n} \cos(\frac{2 n t}{3}) + B_{n} \sin(\frac{2 n t}{3})\bigg)\sin(\frac{n x}{3}) $$