What exact command can I put in a command block to set all players to Adventure Mode?

I need everyone playing the map to be automatically set to adventure mode. How? What is the command?


Solution 1:

Unfortunately, there is no real command to set everyone to a gamemode. You would have to have a command block with the command:

/gamemode 2

And then have all the players hit a button or something to activate the block when they spawn. You could, perhaps, have a spawn room with an iron door, and hook the button to open the door up to a command block.

EDIT: Apparently you can also use

/gamemode 2 @a

To set all players to gamemode 2 (adventure mode).

Solution 2:

Well, you could always set the command /gamemode 2 @a and then run a clock that activates the command block every few seconds.

Then players don't need to click a button.

Solution 3:

Or you could have them spawn on a pressure plate which sets them to adventure mode, and then once they leave the spawn (with a command block teleporter), it will set them to survival mode. This isn't really used for an adventure server, but it's a good way to make the spawn grief-proof without having to make it out of bedrock.

Solution 4:

You can enter the command:

/gamemode 2 @[m=0,r=X]

Set X to the radius you want to have people in the adventure mode.

You can also make a second block with the command:

/ gamemode 0 @a[m=2,rm=x+1]

X+1 will switch the players back into the gamemode survival. This would all be connected to a clock or repeating pulser to always check for players. This is a great world guard for servers and adventure maps.