Okay, I've a problem. I need a command that tests for a player running a specified command.

For example, check whether a player is using /gamemode 1 (in order to reset them)

  • Just don't make players op? That way they won't be able to use any commands? – Arperum Dec 15 '14 at 8:54
  • Interesting question. I edited your question for clarity and brevity, and included your non-answer as well. Please have a look at the Help Center and the Tour to help you get started here on Arqade. – MrLemon Dec 15 '14 at 9:36
  • While thinking of an answer, I realized that this is much easier for certain commands then for others. For example, the gamemode command can easily be detected by its result (someone is in the wrong gamemode). Do you want the question to be narrow (just gamemode) or broad (arbitrary command)? – MrLemon Dec 15 '14 at 9:39

Gamemode can be reset by

/gamemode 0 @a[m=1]

M=0 denotes that they are in creative mode. If to want, you can add a

/tellraw @a[m=1] {"text":"","extra":[{"text":"Creative is not allowed","color":"white","italic":"true"}]}

that is powered just before the above command, to tell players to not use creative.


If you are using a scoreboard (ie, to track total kills), you could use two deathCount (or whatever they are) objectives, and check both of them on a 20Hz clock to see if they are always equal.

/give is harder to track.

You could make a scoreboard objective for every item they could get, and clear items if the player doesn't have enought 'points' for that item.

/setblock is almost impossible to detect.

The only real method here is to /testforblock every block in your map, but that is mega-laggy if you have a map of reasonable size.

The best solution: Don't let anyone be an op.


Actually very simple to do, all you need to do is create a new scoreboard, and for an example let's just call it Admin...

/scoreboard objectives add Admin dummy

then create whatever value you want the Admin score to be... and then in a new command block, just have it test for anyone not with that Admin number and in gamemode 1 if it finds someone, have that player be changed to gamemode 2 or whatever...

testfor @a[score_Admin=(Number 1 less than Admin number),score_Admin_min=(Number 1 more than Admin Number),m=1]

gamemode 2 @a[score_Admin=(Number 1 less than Admin number),score_Admin_min=(Number 1 more than Admin Number),m=1]

so for example, lets say the Admin number is 2026

testfor @a[score_Admin=2025,score_Admin_min=2027,m=1]

gamemode 2 @a[score_Admin=2025,score_Admin_min=2027,m=1]

and you can even add a message to tell those players...

/tellraw @a[score_Admin=2025,score_Admin_min=2027,m=1] {"text":"","extra":[{"text":"Creative is not allowed","color":"white","italic":"true"}]}

Hope this info helps. Play around with it. Also, this way, you can give out Admin number to whomever the admins are, and the admin number can be changed, but make sure to turn off whatever clock you have running (or in 1.9 take off the always active part) before changing numbers in the command blocks and the admins must change to the new number.
Let me know if this helps and if you need help in anything else.


If there is a certain part of game you don't want them to turn creative, you can somehow (Secretly) power a repeat command block that sets the gamemode to survival or adventure. That way if a noob player decides to turn creative, the game will turn back the mode before the noob player can do something. This will ruin the upper left corner of the screen, saying "set game mode to survival" a bunch of times, But its better than a big command. And search the command I forgot it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.