This is a good place to use scoreboard tags. This will allow you to tag any player that has diamond and use that tag to target them within the tp command.
Use 3 command blocks in a chain. The first command block removes the tag from all players. The second command block tags any players who have a diamond in their inventory. The third command block teleports any player within the boundaries of the target selector who do not have the tag.
These command blocks have to remain loaded. I recommend putting them in the spawn chunk. I also recommend stopping command block output to prevent chat spam for op players. Use command:
/gamerule commandBlockOutput false
The first command block is RepeatUnconditionalAlways Active with command:
scoreboard players tag @a remove Obtained
The second command block is ChainUnconditionalAlways Active with command:
scoreboard players tag @a add Obtained {Inventory:[{id:"minecraft:diamond"}]}
The Third command block is ChainUnconditionalAlways Active with command:
tp @a[x=X,y=Y,z=Z,r=R,tag=!Obtained] ~ ~ ~2
Replace X, Y, and Z with the coordinates of your gate area. Replace R with the desired radius for that area.
Pretty easy:
/worldborder
You can set the diameter by /worldborder set <distance>
. For example /worldborder set 5
results in this (a square of 5x5 blocks):
Moving the border is also possible by using /worldborder center <x> <z>
, which will put the border around these coordinates.
Best Answer
If you want to use commandblocks all over the map, you need to place them in the spawn chunk.
The spawnchunk is the area you spawn in (when not using a bed). This chunk is always loaded, so commandblocks will work even if there is no player near it