There's the VillagerReplenishTradeEvent if that would work for you. You might be able to get the inventory of a villager and check if it has the specific thing for trades. I would just try to use the event for whatever you need. You could create a HashMap<Villager, Boolean> and store which ones have been restocked, but I couldn't find a trade event, so I don't know how you would check if it's out... I guess you could then check the villager and see if they have anything in their inventory, or if they have an item of a specific type in their inventory. Hope this helps. I'm not sure if any of this will really work the way you want it to, and I don't know if the villager's inventory is where the stock of trading is from.