Stir together sugar and cornstarch or flour in a heavy medium saucepan. Add milk and chocolate. Cook and stir over medium heat until thickened and bubbly. Cook and stir for 2 minutes more. Remove from heat.
Gradually stir about 1 cup of the hot mixture into the egg yolks. Return all of the egg yolk mixture to saucepan. Bring to a gentle boil. Reduce heat, and cook and stir for 2 minutes more. Remove from heat. Stir in the 2 tablespoons coffee liqueur, if desired, butter or margarine, and vanilla until butter melts. Pour pudding into a bowl. Cover surface with plastic wrap. Chill in the refrigerator, without stirring, for 1 to 24 hours.
About 30 minutes before serving, soak the snipped figs in 2 tablespoons coffee liqueur or warm coffee, stirring occasionally. Drain figs and discard liqueur or coffee. Gently fold figs and pecans or walnuts into the pudding. Makes 6 servings.