Prevent griefing
Solution 1:
Good solution is to use blue (automatic always ticking) commandblock and put it in the centre of your desired protected area.
Inside commandblock, input this command:
/gamemode adventure @a[r=50]
You can change r=50 to any diameter you want to protect. Be warned, that adventure gamemode is not grief-proof, there are things that still can be done - however this is really small portion of things.
Then setup second always running commandblock on top of previous one, and setup second command:
/gamemode survival @a[rm=50]
This one will revert adventure gamemode for anyone leaving this zone.
For more protection, you can use some more always running, each tick working (blue ones) commandblocks to make the area secured, for example (you can find entity types here), but be sure you enter it CASE SENSITIVE, otherwise it will kill everything!!!! (you cannot destroy commandblock killing all players who get near it, you would need to disable commandblocks, destroy it, then enable, so be WARNED that /kill @e
is DANGEROUS, if used wrongly):
/kill @e[type=Creeper,r=50]
/kill @e[type=PrimedTnt,r=50] //ignited tnts
/kill @e[type=Fireball,r=50] //ghast fireballs
/kill @e[type=WitherSkull,r=50]
/kill @e[type=MinecartTNT,r=50]
You can also make checks against building wither or luring enderdragon inside the area, but killing would be probably bad thing, then just teleport them outside area into some safe , open air:
/tp @e[type=WitherBoss,r=50] X Y Z
/tp @e[type=EnderDragon,r=50] X Y Z
Be sure that also silverfish can do some griefing. However this protection can be kinda good enough. It will block mining and placing blocks, also it will block most attempts to destroy "the objective". If you cannot place commandblocks in the centre (and obviously you cannot place all of them on one spot ), then just include x,y,z coords inside brackets, that will set the centre of radius it is efficient in, so:
/gamemode adventure @a[x=100,y=50,z=-100,r=50]
PS: IF you want to make MORE areas on SAME map, then you need to alter the commands with gamemode to ensure that those outer commands don't overlay - then they would set survival to everybody inside second protected area. For workaround for this, make the "leaving" command like this, so it is efficient only in close area near protected area:
/gamemode survival @a[r=80,rm=50]
This will reset gamemode to survival for all people walking out of r=50. If they teleport right away further thna r=80, they won't get resetted, however they are supposed to WANT it resetted to be able playing normally so they should leave normally. or you can do some additional checking or scoreboard tagging (tag everyone inside perimeter, untag everyone else, etc etc)