In a small to medium sized saucepan, whisk together the sugar, sifted cocoa powder, cornflour, and salt. Slowly add half of the milk, whisking to combine.
Set the saucepan over low-medium heat. Stir constantly as the mixture warms. As soon as you see the first signs of a simmer, remove it from the heat.
In a mixing bowl, whisk the egg yolks with the remaining milk. Scoop out 1/4 cup of the hot mixture, while whisking constantly, slowly pour it into the egg yolk mixture to temper it. Then pour the tempered mixture back into the saucepan.
Set the saucepan over medium heat and bring to a simmer. Do not let it boil. Cook until the mixture thickens enough to coat the back of a spoon and some larger bubbles start to break the surface. Remove from the heat.
Stir in the vanilla and peppermint extracts, then stir in the chocolate pieces until melted. The pudding should be thick, smooth, and glossy.
(Optional) If you notice some small bits of cooked egg, you can strain the pudding through a fine mesh sieve.
Pour the pudding into a large bowl. Press cling film directly onto the surface of the pudding to prevent a skin from forming. Let cool at room temperature for 15 minutes, then transfer to the fridge to set for a minimum of 2 hours or overnight.
Remove the cling film and give the pudding a whisk before scooping into glasses or ramekins. Serve topped with chocolate shavings and crushed candy canes.