How to block commands on minecraft?

Solution 1:

Yes, there is a way. When you make the world, you can select Creative mode with no cheats. Now when the world is loaded, entering commands like /gamemode 1 will result in a message saying you don't have permission to use that command. So there is this feature where you can enable cheats in a non-cheat world. Go to the pause menu, then "Open to LAN". From there, select "Enable Cheats". Now you have access to cheats. Note that this cheats mode is temporary, once you quit the world, cheats is deactivated. When building the map, you get access to commands like /give and /gamemode. When you give out the map, the players do not get access to the commands.


TL; DR

To a certain extend, yes you can do that. However, if the players find out about this feature, they can abuse it. Perhaps what you could do is have a armour-stand tracking system and detect a player who teleported away and teleport them back.