Nowaha / Shop-by-Conjurate

1.14 update for the Shop plugin by Conjurate. Original: https://www.spigotmc.org/resources/shop.8185/
0 stars 11 forks source link

Custom item selling #20

Closed zodiuxus closed 4 years ago

zodiuxus commented 4 years ago

I know, this one already exists. But here's the thing, we have no idea if anyone's still working on this project. Since I'm not good at making plugins and such, I thought I could maybe give a suggestion on how to fix this issue. I took a look at the code, I've worked with Java before, just the plugins thing is completely new to me. My idea is that instead of only taking the player's inventory (which I assume only checks the item IDs, not the names), it additionally checks for item names. I searched around and found this: https://www.spigotmc.org/threads/gui-creator-making-inventories-was-never-easier.133942/ and also some 4 year old code: for(ItemStack item : p.getInventory().getItems()) { if(item.getType().equals(Material.PAPER)) { if(item.hasItemMeta()){ String name = item.getItemMeta().getDisplayName() //Or its getCustomName() } } } I know some of these might need some extreme code rework, but I just wanted to open a thread up with this, because the last update on the same issue like this was in November 2019. I enjoy using this plugin and its Citizens integration. Now if only custom items were to be sold properly, I'd enjoy it even more.

Huskehhh commented 4 years ago

Hey! First off thanks for your contribution.

While I am not the developer of this plugin, I did do some development work and bug fixes for it. The fix that would be conflicting with custom item selling would be https://github.com/Nowaha/Shop-by-Conjurate/commit/0dd26c032171f40fc64c71d75f93866178a1bec6

It's a tricky situation, because you either allow custom items sale by comparing utilising something similar to what you've suggested, or, allowing items in the shop to have a different name and players still be able to sell them. Now I can speak for which of these is the intended purpose, but I've since gone and reverted it.. Hopefully it works as intended for you.

https://github.com/Nowaha/Shop-by-Conjurate/commit/31c0f25e5fefe152ca67b1ea20e29ef61f943ed3

Build available at: https://ci.husk.pro/job/Shop-By-Conjurate/4/

zodiuxus commented 4 years ago

Sadly, with the build you gave me it still doesn't work for whatever reason. https://imgur.com/a/LldsVlf Although it does detect that I have an item with such name, it doesn't remove it or give me any money. Is there a way to check for both item name and item ID so that the problem you mentioned wouldn't be encountered?

Huskehhh commented 4 years ago

can you try the latest build