[PR #56] [MERGED] SMP: the server market (/worth, /sell, /buy) #64

Closed
opened 2026-11-03 04:02:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-mods/pull/56
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: feat/smp-market


📝 Commits (3)

  • 7e79501 SMP: the server market (/worth, /sell, /buy)
  • 830bc78 SMP README: players install nothing
  • c13658c Merge main into feat/smp-market

📊 Changes

9 files changed (+679 additions, -55 deletions)

View changed files

📝 native/smp/Cargo.lock (+1 -1)
📝 native/smp/Cargo.toml (+1 -1)
📝 native/smp/README.md (+15 -5)
📝 native/smp/compatibility.json (+2 -2)
📝 native/smp/mixins/smp/glue.rs (+101 -39)
📝 native/smp/mixins/smp/horizon-mixin.toml (+9 -3)
➕ native/smp/mixins/smp/smp_market.rs (+518 -0)
📝 native/smp/proof.py (+30 -4)
📝 native/smp/src/lib.rs (+2 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #55 (the economy): review only the last two commits.

What

The SMP mod's server market, the economy's earning loop (design). Players install nothing: everything is chat commands, shown by a stock Horizon client.

Command Does
/worth [item] what the market pays and asks (the item in your hand when no item is named)
/sell hand [count], /sell <item> [count], /sell all sells to the market
/buy <item> [count] buys, only what fits in your inventory

Prices. They are set in config.json → market.items, each item with buy (what the market asks) and sell (what it pays); 0 closes that side. The defaults are 18 common items, for example diamond buy 400 / sell 100, wheat sell 1, torch buy 1. The section is added to an existing config.json and its values are kept.

Safety.

  • Only plain stacks are counted: no damage, name or enchantment.
  • Only players in survival or adventure mode can trade, so a creative player can't sell what they conjured.
  • On a sale the items move first, then the money. If the money step fails (the log refuses), the items are given back.
  • A purchase checks the money and the room before anything moves.
  • Every sale and purchase is a line in audit.log.

Hook points. It uses the acting player's item helpers, API 9: horizon-rust/horizon#4519. compatibility.json pins "hooks": 9 on that branch's commit. Merge after it and #55.

License

MIT, all original; nothing from other projects. Shop plugins' source was not read.

Proof

native.py proof smp on a dedicated server with two real clients, after the economy checks of #55:

  • Steve in survival was given 3 diamonds and 20 wheat from the console;
  • /worth diamond: "the market pays 100 coins each, sells it for 400 coins each";
  • /sell wheat: "Sold 20 wheat for 20 coins.";
  • /sell hand: "Sold 3 diamond for 300 coins.";
  • /buy torch 5: "Bought 5 torch for 5 coins.";
  • his own client's inventory then counted 0 diamond, 0 wheat and 5 torch;
  • a creative Alex was refused /sell all;
  • after the restart, economy.json held Alex 380 and Steve 435;
  • audit.log read open, open, eco_give, pay, sell 20 minecraft:wheat, sell 3 minecraft:diamond, buy 5 minecraft:torch.

Checks

cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, and cargo test --locked (14 passed).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-mods/pull/56 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat/smp-market` --- ### 📝 Commits (3) - [`7e79501`](https://github.com/horizon-rust/horizon-mods/commit/7e795012ed1b326e5c3bdaee47368734aed3723f) SMP: the server market (/worth, /sell, /buy) - [`830bc78`](https://github.com/horizon-rust/horizon-mods/commit/830bc7884b1f1c04c9768afc364b326f73184a5f) SMP README: players install nothing - [`c13658c`](https://github.com/horizon-rust/horizon-mods/commit/c13658c43043e64dd7caf454cd22862ea1586246) Merge main into feat/smp-market ### 📊 Changes **9 files changed** (+679 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `native/smp/Cargo.lock` (+1 -1) 📝 `native/smp/Cargo.toml` (+1 -1) 📝 `native/smp/README.md` (+15 -5) 📝 `native/smp/compatibility.json` (+2 -2) 📝 `native/smp/mixins/smp/glue.rs` (+101 -39) 📝 `native/smp/mixins/smp/horizon-mixin.toml` (+9 -3) ➕ `native/smp/mixins/smp/smp_market.rs` (+518 -0) 📝 `native/smp/proof.py` (+30 -4) 📝 `native/smp/src/lib.rs` (+2 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Stacked on #55 (the economy): review only the last two commits.** ## What The SMP mod's server market, the economy's earning loop ([design](https://github.com/horizon-rust/horizon/blob/feat/smp-design/docs/smp.md)). Players install nothing: everything is chat commands, shown by a stock Horizon client. | Command | Does | |---|---| | `/worth [item]` | what the market pays and asks (the item in your hand when no item is named) | | `/sell hand [count]`, `/sell <item> [count]`, `/sell all` | sells to the market | | `/buy <item> [count]` | buys, only what fits in your inventory | **Prices.** They are set in `config.json` → `market.items`, each item with `buy` (what the market asks) and `sell` (what it pays); 0 closes that side. The defaults are 18 common items, for example diamond buy 400 / sell 100, wheat sell 1, torch buy 1. The section is added to an existing `config.json` and its values are kept. **Safety.** - Only plain stacks are counted: no damage, name or enchantment. - Only players in survival or adventure mode can trade, so a creative player can't sell what they conjured. - On a sale the items move first, then the money. If the money step fails (the log refuses), the items are given back. - A purchase checks the money and the room before anything moves. - Every sale and purchase is a line in `audit.log`. **Hook points.** It uses the acting player's item helpers, API 9: horizon-rust/horizon#4519. `compatibility.json` pins `"hooks": 9` on that branch's commit. Merge after it and #55. ## License MIT, all original; nothing from other projects. Shop plugins' source was not read. ## Proof `native.py proof smp` on a dedicated server with two real clients, after the economy checks of #55: - Steve in survival was given 3 diamonds and 20 wheat from the console; - `/worth diamond`: "the market pays 100 coins each, sells it for 400 coins each"; - `/sell wheat`: "Sold 20 wheat for 20 coins."; - `/sell hand`: "Sold 3 diamond for 300 coins."; - `/buy torch 5`: "Bought 5 torch for 5 coins."; - his own client's `inventory` then counted 0 diamond, 0 wheat and 5 torch; - a creative Alex was refused `/sell all`; - after the restart, `economy.json` held Alex 380 and Steve 435; - `audit.log` read `open, open, eco_give, pay, sell 20 minecraft:wheat, sell 3 minecraft:diamond, buy 5 minecraft:torch`. ## Checks `cargo fmt --check`, `cargo clippy --all-targets --locked -- -D warnings`, and `cargo test --locked` (14 passed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:02:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mods#64
No description provided.