Minecraft – How to testfor an item in a player’s inventory that gets removed, and add it back

minecraft-commandsminecraft-java-edition

I'm building my own custom created mini-game called murder.

I have 3 teams, and I only have to setup 1 more, but I've ran into a problem; When they get an arrow and shoot it a command block with testfor activates and starts giving them every single time when they have no arrows, an arrow.

The problem is I only want them to give them 1 arrow at a time, so when they shoot that arrow, they get 1 back within 30 ticks of time , but I don't have enough experience with command blocks to do so, anyone who can help me?

Best Answer

I found my own answer after testing, testing, and testing, and here's my solution:

You use scoreboard objectives, and use the testfor command, to look if you have the "use bow" stat. If you used it, the testfor command sends a signal to remove the arrow, and after a specified number of ticks, the arrow is returned.

I used replaceitem, but you can use give.