[PR #55] [MERGED] SMP native server mod: the economy (/balance, /pay, /baltop, /eco) #63

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/55
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: feat/smp-economy


📝 Commits (1)

  • 666479a SMP native server mod: the economy (/balance, /pay, /baltop, /eco)

📊 Changes

15 files changed (+1446 additions, -0 deletions)

View changed files

➕ native/smp/Cargo.lock (+107 -0)
➕ native/smp/Cargo.toml (+16 -0)
➕ native/smp/LICENSE (+21 -0)
➕ native/smp/README.md (+63 -0)
➕ native/smp/compatibility.json (+8 -0)
➕ native/smp/mixins/smp/command.rs (+11 -0)
➕ native/smp/mixins/smp/glue.rs (+179 -0)
➕ native/smp/mixins/smp/horizon-mixin.toml (+67 -0)
➕ native/smp/mixins/smp/lifecycle.rs (+10 -0)
➕ native/smp/mixins/smp/register.rs (+4 -0)
➕ native/smp/mixins/smp/smp_economy.rs (+571 -0)
➕ native/smp/mixins/smp/smp_store.rs (+177 -0)
➕ native/smp/mixins/smp/tick.rs (+12 -0)
➕ native/smp/proof.py (+193 -0)
➕ native/smp/src/lib.rs (+7 -0)

📄 Description

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

What

native/smp/: the official Horizon server's SMP as a native server mod (design, horizon-rust/horizon#4494). This PR is phase 1, the economy. It is not for the registry: Horizon's own server stays plain, and only the official server builds this mod into its engine (NATIVE_NO_DEFAULT_FEATURES=1 native.py build smp). Players install nothing: everything is chat commands with completions, which a stock Horizon client shows.

Command Does
/balance [player], /bal your balance, or another player's
/pay <player> <amount> to a player who has an account
/baltop [page] the richest, 10 a page
/eco give|take|set <player> <amount> level 3 operators, logged

The data lives in world/horizon-smp/:

  • config.json;
  • economy.json: balances by UUID, written whole and atomically (a temporary file, fsync, rename, then the folder's fsync), at most once a tick and when the world closes;
  • audit.log: one JSON line per change, appended before the change.

A damaged economy.json turns the economy off, with the commands saying so, rather than starting from nothing. The currency is in-game only: it can't be bought or cashed out (Mojang's guidelines).

How it is built:

  • smp_store.rs and smp_economy.rs are the rules, with no game types; they are also this crate's modules, with 10 tests (transfers, limits, refusals, the atomic writes, a damaged file, the audit log, UUIDs);
  • glue.rs holds the open world's state and turns the game's types into the rules' types;
  • one small helper per hook.

It hooks only Horizon's hook points:

  • native_register_commands and native_perform_command (API 8, horizon-rust/horizon#4514);
  • the server tick and the world lifecycle.

compatibility.json pins #4514's head, so CI's native.py check applies the mod on it. Merge after #4514, then repin on main.

License

MIT, all original code; nothing from other projects. EssentialsX, Vault and similar plugins were not read: behaviour from their public docs only.

Proof

python3 native/tools/native.py proof smp --resources …/26.3: a dedicated server built with the mod, plus two real clients (horizon-ctl launch --offscreen, connect), on fresh temporary folders.

  • An operator ran /eco give Steve 500: Steve's balance became 500.
  • /pay Alex 120: both players got their line.
  • Refused: paying yourself, paying more than you have, an unknown player, a bad amount.
  • A non-operator sending /eco got vanilla's unknown command.
  • /baltop listed both players.
  • After a clean stop, economy.json and audit.log matched the transactions, and after a restart the balance was the same.

Run on the market branch's head too, which contains this one (#MARKET).

Checks

cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked: 10 passed. native.py check smp on the pinned Horizon: ok.

🤖 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/55 **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-economy` --- ### 📝 Commits (1) - [`666479a`](https://github.com/horizon-rust/horizon-mods/commit/666479ad0580f0ed7d304acc6b735c98e73248c2) SMP native server mod: the economy (/balance, /pay, /baltop, /eco) ### 📊 Changes **15 files changed** (+1446 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `native/smp/Cargo.lock` (+107 -0) ➕ `native/smp/Cargo.toml` (+16 -0) ➕ `native/smp/LICENSE` (+21 -0) ➕ `native/smp/README.md` (+63 -0) ➕ `native/smp/compatibility.json` (+8 -0) ➕ `native/smp/mixins/smp/command.rs` (+11 -0) ➕ `native/smp/mixins/smp/glue.rs` (+179 -0) ➕ `native/smp/mixins/smp/horizon-mixin.toml` (+67 -0) ➕ `native/smp/mixins/smp/lifecycle.rs` (+10 -0) ➕ `native/smp/mixins/smp/register.rs` (+4 -0) ➕ `native/smp/mixins/smp/smp_economy.rs` (+571 -0) ➕ `native/smp/mixins/smp/smp_store.rs` (+177 -0) ➕ `native/smp/mixins/smp/tick.rs` (+12 -0) ➕ `native/smp/proof.py` (+193 -0) ➕ `native/smp/src/lib.rs` (+7 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `native/smp/`: the official Horizon server's SMP as a native server mod ([design](https://github.com/horizon-rust/horizon/blob/feat/smp-design/docs/smp.md), horizon-rust/horizon#4494). This PR is phase 1, the economy. **It is not for the registry**: Horizon's own server stays plain, and only the official server builds this mod into its engine (`NATIVE_NO_DEFAULT_FEATURES=1 native.py build smp`). Players install nothing: everything is chat commands with completions, which a stock Horizon client shows. | Command | Does | |---|---| | `/balance [player]`, `/bal` | your balance, or another player's | | `/pay <player> <amount>` | to a player who has an account | | `/baltop [page]` | the richest, 10 a page | | `/eco give\|take\|set <player> <amount>` | level 3 operators, logged | The data lives in `world/horizon-smp/`: - `config.json`; - `economy.json`: balances by UUID, written whole and atomically (a temporary file, fsync, rename, then the folder's fsync), at most once a tick and when the world closes; - `audit.log`: one JSON line per change, appended *before* the change. A damaged `economy.json` turns the economy off, with the commands saying so, rather than starting from nothing. The currency is in-game only: it can't be bought or cashed out (Mojang's guidelines). How it is built: - `smp_store.rs` and `smp_economy.rs` are the rules, with no game types; they are also this crate's modules, with 10 tests (transfers, limits, refusals, the atomic writes, a damaged file, the audit log, UUIDs); - `glue.rs` holds the open world's state and turns the game's types into the rules' types; - one small helper per hook. It hooks only Horizon's hook points: - `native_register_commands` and `native_perform_command` (API 8, horizon-rust/horizon#4514); - the server tick and the world lifecycle. `compatibility.json` pins #4514's head, so CI's `native.py check` applies the mod on it. **Merge after #4514**, then repin on main. ## License MIT, all original code; nothing from other projects. EssentialsX, Vault and similar plugins were not read: behaviour from their public docs only. ## Proof `python3 native/tools/native.py proof smp --resources …/26.3`: a dedicated server built with the mod, plus two real clients (`horizon-ctl launch --offscreen`, `connect`), on fresh temporary folders. - An operator ran `/eco give Steve 500`: Steve's balance became 500. - `/pay Alex 120`: both players got their line. - Refused: paying yourself, paying more than you have, an unknown player, a bad amount. - A non-operator sending `/eco` got vanilla's unknown command. - `/baltop` listed both players. - After a clean stop, `economy.json` and `audit.log` matched the transactions, and after a restart the balance was the same. Run on the market branch's head too, which contains this one (#MARKET). ## Checks `cargo fmt --check`, `cargo clippy --all-targets --locked -- -D warnings`, `cargo test --locked`: 10 passed. `native.py check smp` on the pinned Horizon: ok. 🤖 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#63
No description provided.