  For every simple Lie algebra $\mathfrak{g}$ we consider the associated Takiff
algebra $\mathfrak{g}^{}_{\ell}$ defined as the truncated polynomial current
Lie algebra with coefficients in $\mathfrak{g}$. We use a matrix presentation
of $\mathfrak{g}^{}_{\ell}$ to give a uniform construction of algebraically
independent generators of the center of the universal enveloping algebra ${\rm
U}(\mathfrak{g}^{}_{\ell})$. A similar matrix presentation for the affine
Kac--Moody algebra $\widehat{\mathfrak{g}}^{}_{\ell}$ is then used to prove an
analogue of the Feigin--Frenkel theorem describing the center of the
corresponding affine vertex algebra at the critical level. The proof relies on
an explicit construction of a complete set of Segal--Sugawara vectors for the
Lie algebra $\mathfrak{g}^{}_{\ell}$.
