I'm making a map, and I want to have a command block or a command block set in the middle of the map that detects when a player picks up 5 diamonds and then replaces those diamonds with a bow and arrow. I've found the command
/execute if data entity @a {Inventory:[{id:"minecraft:diamond",Count:5b}]}
But the only way I've gotten that to work with anything is to do a /give @p command
, but because I want this command to be working with multiple people on the map it won't work, How can I take this output and use it to both clear the diamonds and give 2 items?