Shopkeepers

Shopkeepers

2M Downloads

Shopkeepers / BagOfGold integration

Rocologo opened this issue · 5 comments

commented

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
image

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.

commented

PS. BagOfGold is using vault and works perfect with other economy plugins like

  • Chestshop (buying and selling)
  • Essentials (/eco commands)
  • and many many more.
commented

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 is instanceof 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 via ShopkeepersAPI#getUIRegistry(): If there is an active UISession for the player, you can assume that the currently open inventory is associated with the Shopkeepers plugin.
commented

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.

commented

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

commented

You are probably right because I dont use any of your methods in my plugin. I only check if Shopkeepers is present.