My suggestion would be to modify the following variable in the server.properties file: spawn-protection=999999 Then OP yourself and anyone else you trust to place and destroy blocks.
This forces your world (or at least any realistic distance from spawn) to have spawn protection.
Blocks cannot be placed or destroyed in this area, unless you're an OP (and at least one OP must be listed in order for it to work).
Note that it is currently not possible to fully prevent the griefing you described above in vanilla without tampering with the user's inventory or use of modding tools.
gaming.stackexchange.com/users/27903/Gigazelle
Set their gamemode to adventure mode using /gamemode <plr> adventure .
This makes it so that they cannot break or place blocks.
gaming.stackexchange.com/users/116483/Carcass
So long as a player has blocks or placeable items, they can place them.
Therefore, the only way to prevent placing blocks is to take away a player's inventory with the clear <playername> command.
If there are only a few items you need to prevent from being used this way (e.g., you're specifically concerned about TNT and lava buckets, and nothing else), you can get more specific by using the optional [item] and [metadata] arguments of the clear command to remove only a specific type of item per command.
But if not, then your only recourse is clearing their whole inventory.
gaming.stackexchange.com/users/4163/SevenSidedDie
To the commenter suggesting using @p and the redstone clock he demonstrated, I have two notes.
First, you are looking for @a to select all players.
The selectors are as follows: @p - selects closest player to the command block@a - selects all players@r - selects a random player@e - selects all entities* *including hostile/friendly mobs, players, items/blocks on the ground, etc.
it is *strongly
* recommended you use modifiers to reduce the scope when using @e.
There are far more efficient and faster ways to build clocks, and having fewer repeaters/redstone torches etc is a bonus.
The "Redstone Lag" players often experience is actually the result of block light updates, caused by these devices turning on/off.
The blocks around them are lit up and dimmed with each cycle, and these lighting changes are what crush some machines.
Pure redstone and redstone blocks tend to have less or no impact on lighting.
You can build an incredibly fast clock by simply placing two command blocks against one stone block.
In one command block use /setblock to set a redstone block where the stone block currently is.
Then, in the other command block, tell it to set the redstone block (using the setblock command) to air (minecraft:air).
Lastly, replace the stone block that is adjacent to both command blocks with a redstone block manually.
They will instantly start fighting each other for control of the block and an insanely fast, relatively low impact clock is produced.
I would also suggest running /gamerule
commandBlockOutput
Falseotherwise
your chat will be filled with line after line of "Block Placed".
For clarity's sake, C is a command block, S is the stone block Command: /setblock
x y z minecraft:redstone_blockvC S C
^Command
: /setblock
x y z minecraft:air both sets of x y z should be replaced with the coordinates for the S block.
Use full integers, no decimal places.
Alternatively, you can use relative coordinates.
These are done as ~ ~ ~ instead of numbers.
The three tildes (~) will run the command directly on the command blocks own coordinates.
You can modify relative coordinates using positive or negative values.
In the drawn example above I could use the following integers.
(be sure to know which axis you're adjusting, in this case I've simply used the X axis as an example).
First: /setblock
~1
~ ~ minecraft:redstoneblockSecond:
/setblock
~-1 ~ ~ minecraft:air
This causes the command block to the left to select in the positive direction on the left axis (while maintaining the command blocs y and z).
The block to the right does the exact opposite.
In this example the only axis that changes is X.
The advantage is we can copy this system using a command like clone, or by copying just the code, and not need to adjust the coordinates each time.
It saves a lot of work.
Getting the hang of command blocks is a -big- undertaking, an
gaming.stackexchange.com/users/73678/MisterBuilder
I made a system using command blocks and scoreboard objectives that I call GriefDenial 2.0 .
It's available in schematic file format that you can import into your world using MCedit or other tools that understand schematic files.
This system allows any and all players to create a protected 30×30 area in which only they can build or place blocks, with the ability to add one other trusted user who can also build in their claim.
Since it is built out of command blocks and scoreboard objectives, this is useful for any vanilla server.
gaming.stackexchange.com/users/103891/Guest
You could, Have a command block and make a redstone loop where it goes around and around.
Example: R= Redstone J= Redstone Repeaters.
(Repeaters face oppisite directions)Then, light the redstone with a redstone torch, break torch, and with redstone, as quick as you can break and replace the lit redstone.
RR JJ RR After you have made this, or something like this you need a command block.
In the command block type /clear @p
I think @p is it, there's some code that is everyone.
So this will clear their inventories.
Rapidly, so you don't have to manually do it.
gaming.stackexchange.com/users/63997/Deadly124
use setblock and clone to place air blocks all around the area.
Hook the command blocks up to a fill clock, and that should do the trick.
Note:this will take a LOT of work.
gaming.stackexchange.com/users/137879/Kylun11
Maybe set all players not within an "OP team" and within a certain radius to Adventure mode.
This would mean that you could still edit the spawn, and allow for "survival zones" outside the spawn.
gaming.stackexchange.com/users/158727/Chemical Comrade
I want to know how to keep players from  placing  blocks in a certain area on my Minecraft server using  Command Blocks .  I already know how to keep them from breaking anything via [effect player 'mining fatigue'], but that won't stop them from placing lava, TNT, or anything that might obstruct anything important.  Any suggestions?
How can I use Command Blocks to keep players from placing blocks on a vanilla server?
gaming.stackexchange.com
<minecraft-java-edition><minecraft-commands>
gaming.stackexchange.com/questions/124835
gaming.stackexchange.com/users/52339/Le_Beholder
Try modifying the following variable in the server or clear the player's inventory. The community suggested some ways to tackle the problem.
Opinions by users, regarding some solutions.