Shopkeepers API question: Conditional per-player trades
Hellcode48 opened this issue ยท 1 comments
Is it possible with the API to detect a specific shop item in a specific shopkeeper and have it show or not based on different things. I want to be able to have say the 8th shopkeeper slot shop item only show when a player finished a certain quest.
Some of this is not yet part of the API, so you would have to depend on the implementation. But you could try one of the following:
- Edit a shopkeeper's trades when a player interacts with him. And restore the original trades after the finishes quits trading. This might be an ugly workaround though, and maybe even reliable work with multiple players interacting with the shopkeeper.
- Create a new type of shopkeeper, extending the existing RegularAdminShopkeeper and there you can implement your own logic for List getTradingRecipes(Player player). For example, only returning the trades applicable to that specific player there.
- Listen to the ShopkeeperTradeEvent, figure out where the trading recipe is the one you want to restrict for the player, and then cancel the event. So the player is able to see the trade, but not able to use it.