Shopkeepers / BagOfGold integration
Rocologo opened this issue · 5 comments
Hi,
My users of BagOfGold has asked for Shopkeeprs integration so they can sell and buy items for money (BagOfGold) I have been working on this for a while and it seems that I am close to make it work now.
I have hooked into Shopkeeker and it works fine, but I have one question. How can I test if the Merchant shop is a Shopkeeper shop? Do you have some code I can use?
Kind regards
Rocologo
If you want to try on a test server here is what you must use :
BagOfGold 4.5.1 + CustomItemsLib 1.0.4-SNAPSHOT
https://jenkins.lindegaard.one/job/CustomItemsLib/
Now seems to bee working, but I need some server owners to help me with the testing.
I have tested on these combinations
But I have never played much with the Merchant Inventory, so there might be some actions I dont know.
If you find any bugs, please explain in detail how I can reproduce the bug.
PS. BagOfGold is using vault and works perfect with other economy plugins like
- Chestshop (buying and selling)
- Essentials (/eco commands)
- and many many more.
How can I test if the Merchant shop is a Shopkeeper shop?
I assume by 'merchant' you mean the Bukkit Merchant
of a MerchantInventory
.
I still have to check your solution to understand why you would need to known whether a merchant is a Shopkeeper merchant or a vanilla merchant, but:
- To figure out in general if a
Merchant
is a custom plugin-created merchant, you could check if it isinstanceof AbstractVillger
. This would also detect merchants created by plugins other than the Shopkeepers plugin, and not require a Shopkeepers plugin dependency. - If you really need to know if a particular inventory is associated with the Shopkeepers plugin, you could use
UIRegistry#getUISession(Player)
, accessed viaShopkeepersAPI#getUIRegistry()
: If there is an activeUISession
for the player, you can assume that the currently open inventory is associated with the Shopkeepers plugin.
I have never worked much with the MerchantInventory so I assumed that I would need to check if the MerchantInventory opened is a Shopkeeper Shop or another GUI Shop plugin? But maybe I dont. Maybe it will work on other GUI plugins as well.
I will find some more testes using both Shopkeeper and bagOfGold and ask them to help me with the testing.
But maybe I dont. Maybe it will work on other GUI plugins as well.
Currently, I don't see why you would need to differentiate between Shopkeeper, other custom, or even vanilla merchants: Ideally, your solution would work with all of those, which would also allow users to set up custom vanilla villagers with custom trades that include your bag of gold items