Conversation
|
Sorry for the late reply, I looked at it but didn't have the time to reply directly and forgot. The listener and the module class seem to be the wrong way around now. The listener should be the one reacting to the Bukkit event (ideally the same event should only be used by one listener class in the whole project but that's not the most important thing if it requires too many changes) and the module should then listen on the StockUpdateEvent to change the sign. |
| Bukkit.getScheduler().runTask(ChestShop.getPlugin(), () -> | ||
| fireStockUpdateEvents(event.getDestination())); |
There was a problem hiding this comment.
This should probably directly fire the event, not schedule a task as InventoryMoveItemEvents can occur very frequently and spamming new tasks every time this interact with a shop container seems ill-adviced. (Also I don't see why this should be delayed a tick when it worked without a delay previously already)
This change adds an event
StockUpdateEvent, which fires when the stock inside of a shop changes.ChestShop listens to this event if the
USE_STOCK_COUNTERproperty is set totruein order to update the stock counter on the shop sign. If this property is set tofalseand no other plugins are listening for the event, all logic for this event is disabled and the event is not fired, prioritising performance.