In minecraft, how to make everyone in gamemode 1 except yourself gamemode 2

How to do it

The command you are looking for is

/gamemode 2 @a[name=!You,m=!2]

The m=!2 part makes it so that people in adventure mode are not redundantly put into adventure mode again. Or, more flexibly, create a dummy scoreboard objective (let's call it canCreative) and set it's score to 1 for people allowed in creative mode. Then use:

/gamemode 2 @a[score_canCreative_min=1,m=!2]

(Starting with 1.9, using a scoreboard tag is more appropriate for this.)


Why you shouldn't do it

That said, I strongly advise against doing this. It takes away player agency, with no actual benefit to anyone.

Yes, it does ensure that no-one can use creative mode to cheat, but not only is that of little use in and of itself, since every real benefit of being in creative mode (advanced movement skills, invulnerability, access to blocks, placement of blocks) can be replicated by other commands, e.g. tp, effect, give, setblock, and so on.

But it's not only ineffective at deterring people from cheating, it can also be detrimental to the non-cheating players' fun. No matter how well-designed your map is, chances are someone will somehow break it at some point. If that point is 2 hours into playing your 2.5 hour map, that is frustrating in and of itself.

However, normally, access to creative mode (or spectator mode) offer solutions when you are stuck, by breaking down a door whose mechanism broke, or by manually triggering that mechanism, or even just looking at the mechanism to figure out what you are missing.

At such a point, without access to creative, I personally would just quit and never come back, no matter how amazing your map was before I got stuck. And I don't think I'd be alone in that.