Skip to content

Add restock notifications - #53

Merged
cubefury merged 8 commits into
masterfrom
add-notifications
Dec 23, 2025
Merged

Add restock notifications#53
cubefury merged 8 commits into
masterfrom
add-notifications

Conversation

@cubefury

Copy link
Copy Markdown
Collaborator

This PR aims to adds a notification for when trades come off cooldown.

Closes: GTNewHorizons/GT-New-Horizons-Modpack#22906

Features:

  • Reconnecting to a server will show restocked trades while you were offline.
  • Plays a ding when notifying players of restocked trades
  • Truncates displayed item list if there are more than 5 items in one notification, to prevent chat clutter.
  • Robust to server restarts
  • Notifications are muted when you're already accessing a vending machine
  • Notifications can be disabled, and notification interval can be changed in configs, default enabled, checks every 10s.
  • Clients connecting to servers will inherit the server's notification interval. Disabling notifications server-side disables it for all connected players.

Sample Notifications:
image
image

How it works:

  • Server maintains a notification queue
  • Purchasing item adds a notification to this pending queue, and enables a flag saved in the player's tradestate written to disk
  • Every 10s a player entity exists, the server checks their queue for any trades off cooldown, sends the list to the client, and removes those trades from the notification queue
  • Notifications are generated client-side from the received list
  • If server restarts, trade state is read from disk to populate all players' notification queues

Tested in SP + MP daily 214

@cubefury
cubefury requested a review from a team December 22, 2025 14:06

@chrombread chrombread left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a few quick syntax things

Comment thread src/main/java/com/cubefury/vendingmachine/handlers/NotificationHandler.java Outdated
Comment thread src/main/java/com/cubefury/vendingmachine/handlers/NotificationHandler.java Outdated
Comment thread src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java Outdated
@cubefury

Copy link
Copy Markdown
Collaborator Author

ok I've also swapped a couple other instanceofs to the inline version, will do a more thorough pass on the other files later

@cubefury
cubefury requested a review from chrombread December 23, 2025 06:03

@chrombread chrombread left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm boss. code looks good logic wise but im not familiar with the vending machine codebase but test on server is always good 😎

@cubefury
cubefury merged commit 7c61daa into master Dec 23, 2025
1 check passed
@cubefury
cubefury deleted the add-notifications branch December 23, 2025 06:52
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.

Vending Machine: Add notification for trades coming off of their cooldown

2 participants