[PR #7220] [MERGED] horizon-server: management protocol game rules (gamerules, gamerules/update, gamerules/updated) #7420

Closed
opened 2026-11-03 06:39:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7220
Author: @Akirabane
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/management-notifications-4


📝 Commits (4)

  • 3d10e4c game: one place sets a game rule, and a dedicated server records the change as an event
  • 9540537 game: the management request answers gamerules and gamerules/update
  • 4910a29 horizon-server: the management protocol's gamerules, gamerules/update and gamerules/updated
  • 670867a docs: the management protocol's game rules

📊 Changes

5 files changed (+135 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+22 -2)
📝 crates/horizon-client/src/game/dedicated/management.rs (+71 -0)
📝 crates/horizon-server/src/management_methods.rs (+35 -0)
📝 docs/api/server.md (+2 -2)
📝 docs/server.md (+5 -1)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review.

Refs #7118 (step 4 of 5; steps 1 to 3 are #7121, #7155 and #7198).

What was wrong

The management protocol answered gamerules and gamerules/update with "isn't in Horizon yet", and a client never heard of a game rule changing, which vanilla's JsonRpcNotificationService sends as notification/gamerules/updated.

What changed

  • game/commands.rs: Game::set_game_rule is now the one place a rule is set (the rule, the world's copy through sync_rules) for the /gamerule command and for the protocol. On a dedicated server it records a typed gamerule event with the rule's id, the type of its value and the value, as GameRules.set ends in MinecraftServer.onGameRuleChanged.
  • dedicated/management.rs (the game's management request): gamerules lists every rule the game has as a typed rule ({key, type, value}, as GameRuleUpdate.TYPED_CODEC writes it); gamerules/update sets one after checking the key and the value against the rule's type and bounds, and sets and logs it only when the value changes (Game rule '…' updated from '…' to '…', as MinecraftGameRuleServiceImpl.updateGameRule logs it).
  • management_methods.rs: the supervisor passes both methods to the game (an "invalid" answer becomes an invalid-params error) and turns the gamerule event into notification/gamerules/updated.
  • Docs: docs/server.md section 8, docs/api/server.md.

Four commits: the game's single entry point, the game's two methods, the supervisor's side, the docs. Vanilla classes followed: GameRulesService, GameRulesService$GameRuleUpdate, MinecraftGameRuleServiceImpl, GameRules.set, MinecraftServer.onGameRuleChanged, JsonRpcNotificationService.onGameRuleChanged.

Said so nobody is surprised: the log line names the rule by its short name (pvp), not by its identifier; and the error text for a rule or a value that doesn't fit is Horizon's own, not the codec's (Gson/DFU) message, which this doesn't compare.

How it was checked

  • dedicated/management.rs: a test that a rule is written as the typed codec does, for a boolean and an integer rule.
  • management_methods.rs: the gamerule event becomes notification/gamerules/updated with {key, type, value} (the event keeps the type as valueType, because its own type is its kind).
  • cargo test -p horizon-server (14 management tests) and -p horizon-client --lib dedicated::management; cargo clippy -p horizon-server -p horizon-client --all-targets -- -D warnings and cargo fmt clean. Rebased on main (993eabe86) after #7191's allowlist settings, with a conflict in management_methods.rs resolved by keeping both functions.

Not tested: no run against a real vanilla server (the parity script runs on the maintainers' machines) and no real server with a client calling gamerules or gamerules/update; unlike #7198, no manual run of this step yet.

Next

Step 5 of #7118: server/activity and the status heartbeat.


🔄 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/pull/7220 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/management-notifications-4` --- ### 📝 Commits (4) - [`3d10e4c`](https://github.com/horizon-rust/horizon/commit/3d10e4cb7952a78a0daa1cc027b826d37a4a2a25) game: one place sets a game rule, and a dedicated server records the change as an event - [`9540537`](https://github.com/horizon-rust/horizon/commit/95405375474ca876349a303a939045afbc7ab337) game: the management request answers gamerules and gamerules/update - [`4910a29`](https://github.com/horizon-rust/horizon/commit/4910a29ddc064b62be9d407edb5f7c643b7eecb0) horizon-server: the management protocol's gamerules, gamerules/update and gamerules/updated - [`670867a`](https://github.com/horizon-rust/horizon/commit/670867a1fb21b2db26e604d73757c29f646417d5) docs: the management protocol's game rules ### 📊 Changes **5 files changed** (+135 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+22 -2) 📝 `crates/horizon-client/src/game/dedicated/management.rs` (+71 -0) 📝 `crates/horizon-server/src/management_methods.rs` (+35 -0) 📝 `docs/api/server.md` (+2 -2) 📝 `docs/server.md` (+5 -1) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review. Refs #7118 (step 4 of 5; steps 1 to 3 are #7121, #7155 and #7198). ## What was wrong The management protocol answered `gamerules` and `gamerules/update` with "isn't in Horizon yet", and a client never heard of a game rule changing, which vanilla's `JsonRpcNotificationService` sends as `notification/gamerules/updated`. ## What changed - `game/commands.rs`: `Game::set_game_rule` is now the one place a rule is set (the rule, the world's copy through `sync_rules`) for the `/gamerule` command and for the protocol. On a dedicated server it records a typed `gamerule` event with the rule's id, the type of its value and the value, as `GameRules.set` ends in `MinecraftServer.onGameRuleChanged`. - `dedicated/management.rs` (the game's management request): `gamerules` lists every rule the game has as a typed rule (`{key, type, value}`, as `GameRuleUpdate.TYPED_CODEC` writes it); `gamerules/update` sets one after checking the key and the value against the rule's type and bounds, and sets and logs it only when the value changes (`Game rule '…' updated from '…' to '…'`, as `MinecraftGameRuleServiceImpl.updateGameRule` logs it). - `management_methods.rs`: the supervisor passes both methods to the game (an "invalid" answer becomes an invalid-params error) and turns the `gamerule` event into `notification/gamerules/updated`. - Docs: `docs/server.md` section 8, `docs/api/server.md`. Four commits: the game's single entry point, the game's two methods, the supervisor's side, the docs. Vanilla classes followed: `GameRulesService`, `GameRulesService$GameRuleUpdate`, `MinecraftGameRuleServiceImpl`, `GameRules.set`, `MinecraftServer.onGameRuleChanged`, `JsonRpcNotificationService.onGameRuleChanged`. Said so nobody is surprised: the log line names the rule by its short name (`pvp`), not by its identifier; and the error text for a rule or a value that doesn't fit is Horizon's own, not the codec's (Gson/DFU) message, which this doesn't compare. ## How it was checked - `dedicated/management.rs`: a test that a rule is written as the typed codec does, for a boolean and an integer rule. - `management_methods.rs`: the `gamerule` event becomes `notification/gamerules/updated` with `{key, type, value}` (the event keeps the type as `valueType`, because its own `type` is its kind). - `cargo test -p horizon-server` (14 management tests) and `-p horizon-client --lib dedicated::management`; `cargo clippy -p horizon-server -p horizon-client --all-targets -- -D warnings` and `cargo fmt` clean. Rebased on main (993eabe86) after #7191's allowlist settings, with a conflict in `management_methods.rs` resolved by keeping both functions. Not tested: no run against a real vanilla server (the parity script runs on the maintainers' machines) and no real server with a client calling `gamerules` or `gamerules/update`; unlike #7198, no manual run of this step yet. ## Next Step 5 of #7118: `server/activity` and the status heartbeat. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:17 +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#7420
No description provided.