[PR #407] [MERGED] Commands follow the world's Allow Commands #2543

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/407
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/allow-commands


📝 Commits (3)

  • d149507 Commands follow the world's Allow Commands (#372)
  • e0b5e25 Commands: prune suggestions in the chat only, like the client's tree
  • 964280a Guests on a dedicated server keep their ops-based commands

📊 Changes

12 files changed (+111 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/chat.rs (+3 -1)
📝 crates/horizon-client/src/command/mod.rs (+24 -2)
📝 crates/horizon-client/src/command/tests.rs (+36 -0)
📝 crates/horizon-client/src/game.rs (+5 -3)
📝 crates/horizon-client/src/game/agent.rs (+1 -1)
📝 crates/horizon-client/src/game/chat.rs (+25 -1)
📝 crates/horizon-client/src/game/command_harness.rs (+3 -1)
📝 crates/horizon-client/src/game/dedicated.rs (+1 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+4 -1)
📝 crates/horizon-client/src/game/lan_screen.rs (+5 -3)
📝 crates/horizon-client/src/save.rs (+3 -2)
📝 tools/test_save_roundtrip_parity.py (+1 -1)

📄 Description

Fixes #372

What vanilla does

IntegratedServer.getProfilePermissions: the single-player owner is LevelBasedPermissionSet.OWNER (4) only when PlayerList.isOp holds. For the owner that is worldData.isAllowCommands(). Otherwise the owner gets ALL (0). The client only gets the command nodes it may use (Commands.sendCommands prunes by canUse), so /gamemode and the like are neither suggested nor run: "Unknown or incomplete command". At level 0 the integrated server leaves help list me msg random seed teammsg tell tm trigger version w. seed and version are only gated on dedicated servers (Commands.java, CommandSelection.INTEGRATED).

Fix

  • Horizon set the owner's level to 4 in every world. It now follows allowCommands: Game::allow_commands, plus owner_permission for the level and set_allow_commands, used by World Options as IntegratedServer.setWorldAllowCommands does.
  • Level::read reads allowCommands from level.dat. Before, every Horizon save wrote 0 unless the world came from the Create screen, and nothing read it. A world created without the Create screen (--world, horizon-ctl open) takes that screen's default: on for Creative only.
  • Suggestions skip nodes above the player's level, like the pruned tree on a vanilla client.
  • Commands the game issues itself still run at the owner's level (Game::as_console): the dedicated server console, the command harness, the World Options difficulty change (vanilla calls setDifficulty directly), and horizon-ctl command, which agents and harnesses use the way an operator console is used. horizon-ctl chat /… types as the player, so it follows Allow Commands.
  • The removed cheats field (always true) had been gating LAN guest commands. That check now reads the world's setting.
  • tools/test_save_roundtrip_parity.py set its game rules with chat /gamerule on a dedicated-server world (allowCommands 0). It now uses command.

Verified

  • Unit test command::tests::commands_need_allow_commands: at level 0, gamemode creative → command.unknown.command, me waves runs, and the root suggestions are exactly the 12 vanilla commands above. cargo test -p horizon-client --lib -- command:: chat passes (16 tests), and so does save::tests::level_round_trips_through_the_vanilla_files.
  • In the game, offscreen with horizon-ctl, I created a Survival world through the title screen menus (Allow Commands off by default):
    • /gamemode creative gives "Unknown or incomplete command. See below for error". /me waves gives "* Player waves".
    • Typing /t suggests only teammsg, tell, tm, trigger (screenshot checked).
    • After Save and Quit and reopening, /time set day is still refused, so the setting is read back from level.dat.
    • horizon-ctl command gamemode creative still works ("Set own game mode to Creative Mode").

Self-check (combined branch of the batch's seven PRs, #406 #407 #409 #414 #416 #421 #423, on origin/main d28521f7; Mac mini):

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client: 775 passed, 0 failed
  • tools/parity.py --changed origin/main (82 harnesses, including the new world_reopen): 82 pass.
    • The first pass found two #407 regressions, both fixed in #407 and rerun green: command_parse (suggestions were pruned in brigadier itself rather than only in the player's chat) and dedicated_server (dedicated-server guests lost their ops-based commands).
    • 34 harnesses passed on the combined commit before those two #407 fixes. The other 48 plus the two reruns passed after them.
  • Not run: the Linux and Windows checks (this batch was developed and checked on the Mac mini only).

🤖 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/pull/407 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/allow-commands` --- ### 📝 Commits (3) - [`d149507`](https://github.com/horizon-rust/horizon/commit/d1495076e6180e63ea147043c3b867fe3d081e99) Commands follow the world's Allow Commands (#372) - [`e0b5e25`](https://github.com/horizon-rust/horizon/commit/e0b5e25c1a1e682c3aed5cf7050588ba84c9aad1) Commands: prune suggestions in the chat only, like the client's tree - [`964280a`](https://github.com/horizon-rust/horizon/commit/964280aa000b1e5942615a18d77f6615499436e2) Guests on a dedicated server keep their ops-based commands ### 📊 Changes **12 files changed** (+111 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/chat.rs` (+3 -1) 📝 `crates/horizon-client/src/command/mod.rs` (+24 -2) 📝 `crates/horizon-client/src/command/tests.rs` (+36 -0) 📝 `crates/horizon-client/src/game.rs` (+5 -3) 📝 `crates/horizon-client/src/game/agent.rs` (+1 -1) 📝 `crates/horizon-client/src/game/chat.rs` (+25 -1) 📝 `crates/horizon-client/src/game/command_harness.rs` (+3 -1) 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+4 -1) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+5 -3) 📝 `crates/horizon-client/src/save.rs` (+3 -2) 📝 `tools/test_save_roundtrip_parity.py` (+1 -1) </details> ### 📄 Description Fixes #372 ## What vanilla does `IntegratedServer.getProfilePermissions`: the single-player owner is `LevelBasedPermissionSet.OWNER` (4) only when `PlayerList.isOp` holds. For the owner that is `worldData.isAllowCommands()`. Otherwise the owner gets `ALL` (0). The client only gets the command nodes it may use (`Commands.sendCommands` prunes by `canUse`), so `/gamemode` and the like are neither suggested nor run: "Unknown or incomplete command". At level 0 the integrated server leaves `help list me msg random seed teammsg tell tm trigger version w`. `seed` and `version` are only gated on dedicated servers (`Commands.java`, `CommandSelection.INTEGRATED`). ## Fix - Horizon set the owner's level to 4 in every world. It now follows `allowCommands`: `Game::allow_commands`, plus `owner_permission` for the level and `set_allow_commands`, used by World Options as `IntegratedServer.setWorldAllowCommands` does. - `Level::read` reads `allowCommands` from level.dat. Before, every Horizon save wrote 0 unless the world came from the Create screen, and nothing read it. A world created without the Create screen (`--world`, horizon-ctl `open`) takes that screen's default: on for Creative only. - Suggestions skip nodes above the player's level, like the pruned tree on a vanilla client. - Commands the game issues itself still run at the owner's level (`Game::as_console`): the dedicated server console, the command harness, the World Options difficulty change (vanilla calls `setDifficulty` directly), and horizon-ctl `command`, which agents and harnesses use the way an operator console is used. horizon-ctl `chat /…` types as the player, so it follows Allow Commands. - The removed `cheats` field (always `true`) had been gating LAN guest commands. That check now reads the world's setting. - `tools/test_save_roundtrip_parity.py` set its game rules with `chat /gamerule` on a dedicated-server world (allowCommands 0). It now uses `command`. ## Verified - Unit test `command::tests::commands_need_allow_commands`: at level 0, `gamemode creative` → `command.unknown.command`, `me waves` runs, and the root suggestions are exactly the 12 vanilla commands above. `cargo test -p horizon-client --lib -- command:: chat` passes (16 tests), and so does `save::tests::level_round_trips_through_the_vanilla_files`. - In the game, offscreen with horizon-ctl, I created a Survival world through the title screen menus (Allow Commands off by default): - `/gamemode creative` gives "Unknown or incomplete command. See below for error". `/me waves` gives "* Player waves". - Typing `/t` suggests only `teammsg, tell, tm, trigger` (screenshot checked). - After Save and Quit and reopening, `/time set day` is still refused, so the setting is read back from level.dat. - horizon-ctl `command gamemode creative` still works ("Set own game mode to Creative Mode"). **Self-check** (combined branch of the batch's seven PRs, #406 #407 #409 #414 #416 #421 #423, on origin/main d28521f7; Mac mini): - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client`: 775 passed, 0 failed - `tools/parity.py --changed origin/main` (82 harnesses, including the new `world_reopen`): 82 pass. - The first pass found two #407 regressions, both fixed in #407 and rerun green: `command_parse` (suggestions were pruned in brigadier itself rather than only in the player's chat) and `dedicated_server` (dedicated-server guests lost their ops-based commands). - 34 harnesses passed on the combined commit before those two #407 fixes. The other 48 plus the two reruns passed after them. - Not run: the Linux and Windows checks (this batch was developed and checked on the Mac mini only). 🤖 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-02 15:57: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#2543
No description provided.