[PR #5825] [MERGED] Native mods: any command a player types, cancellable (native_player_command, part of #5816) #6515

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5825
Author: @Detimes
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: feat-player-command-hook


📝 Commits (3)

  • 64c3a68 Native mods: any command a player types, cancellable (native_player_command)
  • 9802a6d Merge remote-tracking branch 'hr/main' into pr-5825
  • 2a1b8a3 Player command hook: hear quiet command batches, name it canceled, catalog keys

📊 Changes

5 files changed (+77 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+24 -0)
📝 crates/horizon-client/src/game/lan_quiet.rs (+12 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+22 -0)
📝 docs/native-mods.md (+6 -0)
➕ tools/native-hook-fragments/native_player_command.json (+13 -0)

📄 Description

🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally.

What and why

Part of #5816 (hook points a survival server's native mods need). A native mod can only hear commands it registered itself (native_perform_command). A server mod that logs commands, blocks some, or hides others from a role has no way to see the rest: vanilla's commands, and commands the player may not run.

  • New hook point native_player_command(player, name, command, cancel, replies), API number from the fragment (tools/native-hook-fragments/native_player_command.json), a paragraph in docs/native-mods.md.
  • Called first in guest_command (lan_actions.rs), before the list/message/unmute special cases, the native-command routing and the permission check, for every command a player sends. cancel stops it; lines pushed to replies are sent to the player as system chat (native_tell reaches nobody in this spot, because the hub is taken out of the game while a guest's packet is handled).
  • Nothing changes when no mod hooks it.

Kind

  • feature (new native hook point)

Vanilla reference

NeoForge's CommandEvent (fired in Commands.performCommand before the dispatcher runs, cancellable). Horizon's equivalent entry is guest_command.

Other projects' code

none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.)

Proof on a real dedicated server

Engine built from this branch plus the branch of the other hook in #5816 (native_player_respawned, #5820) with a throwaway horizon-mixins bundle whose helper cancels list and replies "[mod] list blocked". Fresh world, offline mode, a protocol client (not op) types commands in chat:

/list  (mod cancels)      -> text [mod] list blocked          (no player list)
/seed  (mod leaves alone) -> command.unknown.command           (as before for a non-operator)

Control, same server without the bundle: /list answers the player list. A first version of this PR called the hook from run_guest_command, which /list and commands of non-operators never reach; the proof showed it, so the call moved to the top of guest_command.

Not covered: commands from the single player owner, and the console (#5682 / #5815).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on leoserver, against upstream/main at b4e123280, 7 min 47 s)

Check Result
Scope ✅ 4 files, +56 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (58 s)
rustfmt ✅ (16 s)
clippy ✅ (3 min 56 s)
tests: horizon-client ✅ 1659 passed (2 min 33 s)
doc tests ✅ 0 passed (4 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/5825 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat-player-command-hook` --- ### 📝 Commits (3) - [`64c3a68`](https://github.com/horizon-rust/horizon/commit/64c3a68a7195e3432543aca19961e73f5257930d) Native mods: any command a player types, cancellable (native_player_command) - [`9802a6d`](https://github.com/horizon-rust/horizon/commit/9802a6dccb17194533cbce8ee45f0f905aa60d35) Merge remote-tracking branch 'hr/main' into pr-5825 - [`2a1b8a3`](https://github.com/horizon-rust/horizon/commit/2a1b8a321a6f0699748a9ee4fe3850982af66398) Player command hook: hear quiet command batches, name it canceled, catalog keys ### 📊 Changes **5 files changed** (+77 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+24 -0) 📝 `crates/horizon-client/src/game/lan_quiet.rs` (+12 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+22 -0) 📝 `docs/native-mods.md` (+6 -0) ➕ `tools/native-hook-fragments/native_player_command.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally. ## What and why Part of #5816 (hook points a survival server's native mods need). A native mod can only hear commands it registered itself (`native_perform_command`). A server mod that logs commands, blocks some, or hides others from a role has no way to see the rest: vanilla's commands, and commands the player may not run. - New hook point `native_player_command(player, name, command, cancel, replies)`, API number from the fragment (`tools/native-hook-fragments/native_player_command.json`), a paragraph in `docs/native-mods.md`. - Called first in `guest_command` (`lan_actions.rs`), before the list/message/unmute special cases, the native-command routing and the permission check, for every command a player sends. `cancel` stops it; lines pushed to `replies` are sent to the player as system chat (`native_tell` reaches nobody in this spot, because the hub is taken out of the game while a guest's packet is handled). - Nothing changes when no mod hooks it. ## Kind - [x] feature (new native hook point) ## Vanilla reference NeoForge's `CommandEvent` (fired in `Commands.performCommand` before the dispatcher runs, cancellable). Horizon's equivalent entry is `guest_command`. ## Other projects' code none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.) ## Proof on a real dedicated server Engine built from this branch plus the branch of the other hook in #5816 (`native_player_respawned`, #5820) with a throwaway horizon-mixins bundle whose helper cancels `list` and replies "[mod] list blocked". Fresh world, offline mode, a protocol client (not op) types commands in chat: ``` /list (mod cancels) -> text [mod] list blocked (no player list) /seed (mod leaves alone) -> command.unknown.command (as before for a non-operator) ``` Control, same server without the bundle: `/list` answers the player list. A first version of this PR called the hook from `run_guest_command`, which `/list` and commands of non-operators never reach; the proof showed it, so the call moved to the top of `guest_command`. Not covered: commands from the single player owner, and the console (#5682 / #5815). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on leoserver, against upstream/main at b4e123280, 7 min 47 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +56 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (58 s) | | rustfmt | ✅ (16 s) | | clippy | ✅ (3 min 56 s) | | tests: horizon-client | ✅ 1659 passed (2 min 33 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:22:03 +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#6515
No description provided.