Creating Pet collected hp&mp&vigors back to inventory in farming area.

Hello guys i m not good with plugin codings all i need how do i make collected HP and MP - Vigor and Arrows back to inventory while attacking mobs or in farming areA !

can someone show me how do i make this code. can you create 1 example for what i said.

pick-up pet inventory to character inventory in time when arrow less than 250 or pots are less than 50.