Skip to content

Add StockUpdateEvent#644

Open
bjorn-out wants to merge 2 commits intoChestShop-authors:masterfrom
bjorn-out:stock-update-event
Open

Add StockUpdateEvent#644
bjorn-out wants to merge 2 commits intoChestShop-authors:masterfrom
bjorn-out:stock-update-event

Conversation

@bjorn-out
Copy link

@bjorn-out bjorn-out commented Nov 7, 2025

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_COUNTER property is set to true in order to update the stock counter on the shop sign. If this property is set to false and no other plugins are listening for the event, all logic for this event is disabled and the event is not fired, prioritising performance.

@Phoenix616
Copy link
Member

Phoenix616 commented Nov 30, 2025

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.

Comment on lines +36 to +37
Bukkit.getScheduler().runTask(ChestShop.getPlugin(), () ->
fireStockUpdateEvents(event.getDestination()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants