Instead of testing for a gamemode NBT tag, why don't you use the gamemode selector instead?
/testforexecute if entity @a[gamemode=adventure]
If you want to mark players, you can use a /scoreboard
command with the selectors set to @a[gamemode=adventure]
.
Before 1.13, it is /testfor @a[m=2]
, but as of 1.13, m
was renamed to gamemode
, /testfor
was renamed to /execute if entity
, and the argument is now the name of the mode.
Props to @ppperry for notifying me of this.