Block free (b:0 / s:0) shops; break pre-existing ones on interact#3
Merged
Conversation
Free shops — a buy or sell price of exactly 0 — are an abuse vector. Disallow them and clean up any that already exist. - PreShopCreation/FreePriceChecker (NORMAL, after PriceChecker normalises the price line): rejects creation with INVALID_PRICE if the buy or sell price is 0. An unoffered side (NO_PRICE / -1) is unaffected, so non-zero buy-only or sell-only shops still work. - PreTransaction/FreeShopBreaker (LOWEST): the first time anyone interacts with a pre-existing free shop, cancel the trade with INVALID_SHOP (sends the "invalid shop" message via ErrorMessageSender) and destroy the sign (ShopDestroyedEvent → de-register, then breakNaturally). - Register both in ChestShop.registerEvents(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free shops — a buy or sell price of exactly 0 — are an abuse vector. This disallows them and cleans up any that already exist.
Behaviour
PreShopCreation/FreePriceCheckerruns afterPriceCheckernormalises the price line and rejects creation (INVALID_PRICE) when the buy or sell price is 0. An unoffered side (NO_PRICE= -1) is untouched, so a normal buy-only / sell-only shop with a non-zero price still works fine.PreTransaction/FreeShopBreaker(LOWEST): the first time someone clicks a free shop, the trade is cancelled withINVALID_SHOP(which sends the "invalid shop" message viaErrorMessageSender) and the sign is destroyed — firingShopDestroyedEvent(so it's de-registered from the market) thenbreakNaturally().ChestShop.registerEvents().Notes
PriceUtil.getExactBuyPrice/SellPriceand compares toPriceUtil.FREE(0), soB 0,S 0,B 0:S 5, bare0, etc. are all caught after normalisation.mvn -pl plugin -am compilepasses. Listener logic is Bukkit-event-coupled (no unit layer in the plugin); worth a quick in-game smoke test: try to create aB 0shop (should be rejected), and click an existing free shop (should break with the invalid-shop message).🤖 Generated with Claude Code