Skip to content

Fix shop sign [stock color] desync on load (stuck “out of stock” red)#41

Merged
OstlerDev merged 1 commit intomasterfrom
stock-sign-color-bug
Dec 18, 2025
Merged

Fix shop sign [stock color] desync on load (stuck “out of stock” red)#41
OstlerDev merged 1 commit intomasterfrom
stock-sign-color-bug

Conversation

@OstlerDev
Copy link
Copy Markdown
Collaborator

Users were reporting shops having stock but displaying red as out of stock (seems to just be a visual issue) as they can still buy from them

image1 image2

(AI Generated description)

Problem

Some shops display the [shop] line in out_of_stock color (red) even when they have stock and transactions still succeed. Hover info correctly shows stock, but the sign’s color can remain stale after startup/load.

Root Cause

  • Sign lines are generated from cached stock.
  • During shop load, sign rendering could occur before stock was restored from disk, and later load() could skip refreshing the sign if updateStock() recomputed the same value (no “stock change” → no forced sign update, while updateSign() is gated by signLinesRequireRefresh).

Fix

  • Load ordering: In ShopHandler.loadShopsFromConfig(), apply setStockOnLoad(stock) before setItemStack() / setSecondaryItemStack() to avoid early sign rendering with default stock=0.
  • Load refresh safety: In AbstractShop.load(), set signLinesRequireRefresh = true immediately before updateStock() so the sign is refreshed even when oldStock == newStock.

Tests

  • Added ShopSignStockColorDesyncOnLoadTest to reproduce the stuck-red sign scenario and verify the sign updates to in-stock color after load() when stock > 0.
  • Ran mvn -pl core test successfully.

Risk / Compatibility

Changes are limited to shop load initialization and sign refresh behavior; no transaction logic changes.

@github-actions
Copy link
Copy Markdown

Build Completed Successfully! 🎉

Version: 1.10.2-696d211
Diff Cover: View report

Download Build

⬇️ shop-1.10.2-696d211.jar

@github-actions
Copy link
Copy Markdown

Coverage Report

Overall Project 38.92% -0.02% 🟢
Files changed 25% 🔸

File Coverage
AbstractShop.java 60.56% 🟢
ShopHandler.java 41% -0.23% 🔸

@OstlerDev OstlerDev merged commit 05533c8 into master Dec 18, 2025
2 checks passed
@OstlerDev OstlerDev deleted the stock-sign-color-bug branch December 18, 2025 05:23
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.

1 participant