GUI Shop

GUI Shop

273k Downloads

Feature Request: Show Sell-Price in Sell GUI

A248 opened this issue · 4 comments

commented

This feature was suggested by Coco on the Discord. It will look like this:
Feature Preview

The price will of course be updated whenever a user adds an item to the GUI. The item display name will be set to reflect the price.

commented

Also, we need to remember to change the name back if a user withdraws the item from the sell GUI.

This means it would be necessary to maintain a map of items to display names. When an item is added to the GUI, its actual display name must be added to the map. Then, its display name can be changed to the desired display, e.g. "Value: ##.#". If a player takes the item out of the sell GUI before closing it, then the item's actual display name will be restored before it is added to their inventory.

commented

For now I won't be working on this feature since I have too many other things to do at the moment, so I'll let you know what I've found out.

The spigot docs are notably unclear in general but in particular with regards to how events are triggered. Sometimes method calls trigger events – player.teleport(Location) triggers the PlayerTeleportEvent and Entity.setHealth(0) a death event. Also, some events lead to others: the PlayerTeleportEvent comes before the PlayerChangedWorldEvent.

With regards to GUIs, it isn't clear whether the InventoryDragEvent leads to the InventoryClickEvent. GUIShop uses the library IF, which doesn't listen to the InventoryDragEvent, which suggests it isn't required. However, the SkRayFall source, which implements a StoreEvent, clearly listens to the InventoryDragEvent, implying it is a possible way for players to add items to a GUI.

If this feature request is to be implemented, we have to be sure of these details in order to determine the exact moments and causes why an item is added to the GUI. InventoryClickEvent's InventoryAction has quite a few values.

I may just be less knowledgeable on this topic, so anyone is free to cast doubt on my conjectures and assumptions. If you discover anything let me know; I'd like to know.

commented

The only thing I'd suggest is using the InventoryInteractEvent. Perhaps check if the player clicked the player GUI while /sell is open. If so, delete the clicked itemstack, duplicate it with the sell lore, and add it to the first available slot in the sell gui, the only thing is this would require us to use NBT to store the sell value, which breaks item stacking. I think this feature request will have to be declined.

How about we do a /guishop price command where you drop all the items into a empty inventory (like sell) but it compares against PRICETABLE and displays the total price you;d get if you sold everything in the GUI.

commented

I decided I won't be working on this feature request anytime in the foreseeable future. If anyone wants to make a PR feel free.