How do I make no one able to break blocks?

I made a Kit PvP world and when my friends play they destroy everything. I don't want to keep rebuilding everytime.

Is there a command with which they can't break any blocks anymore ?


Solution 1:

Use Adventure Mode (/gamemode 2), this way players aren't able to destroy anything except things like vines or tall grass but they are able to do other actions like opening chests or fighting with swords.

The command to set everyone to Adventure mode is: /gamemode 2 @a

Solution 2:

But, if you still want to let players place things, that does not work. Another way is to give everyone mining fatigue by using the following:

/effect player effect seconds amplifier

For example:

/effect @a mining_fatigue 100 100, and have a clock running with command blocks with that continence.

Here's a way to hide the text that says that it did it, Do /gamerule DoCommandOutput False