This example shows you different ways to execute 'commands' for Minecraft from code:
EntityPlayerSP player = Minecraft.getMinecraft().player; player.sendChatMessage("/Command here");
to send a command in SinglePlayer