mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-13 20:13:13 -10:00
Native mods: a registered command run from a single player's owner console
The owner console (horizon-ctl command, the MCP command tool) ran every line through the vanilla dispatcher, so a command a native mod registered answered "Unknown or incomplete command". It now offers a registered name to native_perform_command first, as the owner at level 4, the way the owner's own chat does. The dedicated console was done in #5815. Fixes #5682. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
9f683428a6
commit
c73e087d70
3 files changed
+11
-3
No files matched your search
@@ -869,7 +869,12 @@ impl Game<'_> {
|
||||
self.lan = Some(host);
|
||||
let lines = self.as_console(|g| {
|
||||
g.chat_capture = Some(Vec::new());
|
||||
g.run_command(&command);
|
||||
// A command a native mod registered goes to the mods
|
||||
// first, as the owner's own chat does (the console is
|
||||
// level 4, so every registered usage is allowed).
|
||||
if !g.perform_native_command(conn, 4, command.trim()) {
|
||||
g.run_command(&command);
|
||||
}
|
||||
g.chat_capture.take().unwrap_or_default()
|
||||
});
|
||||
host = self.lan.take().expect("a command puts the hub back");
|
||||
|
||||
@@ -2173,7 +2173,9 @@ impl Game<'_> {
|
||||
/// without its slash, for a command a mod registered and the player's
|
||||
/// level allows: set `ran` when it is yours. The player's state is
|
||||
/// swapped in for the call, so `native_player` and the other helpers
|
||||
/// read that player; `native_feedback` answers them. API 8.
|
||||
/// read that player; `native_feedback` answers them. A single player's
|
||||
/// owner console (`horizon-ctl command`) reaches it too, as the owner at
|
||||
/// level 4. API 8.
|
||||
pub(super) fn native_perform_command(
|
||||
&mut self,
|
||||
player: &NativeServerPlayer,
|
||||
|
||||
+2
-1
@@ -969,7 +969,8 @@ For mods that run where the world is simulated: a dedicated server, a LAN host,
|
||||
- **`native_perform_console_command(command, ran)`**: a registered command typed on the dedicated server's console
|
||||
(without its slash), run as the server at level 4: no player, so `native_acting_player()` is None and the player-only
|
||||
helpers give nothing. The mod parses the line and sets `ran`; `native_feedback` answers on the console. A name no mod
|
||||
registered goes to vanilla's dispatcher as before; the single player owner's console is not covered.
|
||||
registered goes to vanilla's dispatcher as before. The single player owner's console (`horizon-ctl command`, the MCP
|
||||
command tool) is a player's: it reaches `native_perform_command` with the owner, at level 4.
|
||||
- **`native_player_respawned(player, name)`**: a dead player came back, once per respawn, on a server: after
|
||||
`PlayerList.respawn` reset their health, food and experience and placed them at their bed, anchor or the world spawn
|
||||
(NeoForge's `PlayerRespawnEvent`). The player's state is swapped in for the call, as for their other actions, so
|
||||
|
||||
Reference in new issue
Block a user