Skip to content

feat: add runCommand/useRunCommand for page-triggered commands - #2

Merged
KoSHeroff merged 1 commit into
mainfrom
feat/run-command
Jul 25, 2026
Merged

feat: add runCommand/useRunCommand for page-triggered commands#2
KoSHeroff merged 1 commit into
mainfrom
feat/run-command

Conversation

@KoSHeroff

Copy link
Copy Markdown
Member

What

Adds runCommand and the useRunCommand() hook so a page can run a Minecraft command, which the mod executes as the player.

import { runCommand, useRunCommand } from '@webgui/react';

runCommand('give @s minecraft:diamond 1');

const run = useRunCommand();
<button onClick={() => run('spawn')}>Teleport to spawn</button>

Fire-and-forget: it posts on the command channel; the mod runs it only when the page is served from a server-declared trusted origin, and drops it otherwise.

Changes

  • runCommand(command) util + useRunCommand() hook.
  • Tests for runCommand.
  • Bump to 1.6.0.

Pairs with the mod PR adding the command channel + trusted-origin enforcement.

Verification

  • npm run build succeeds; 32 tests pass.

runCommand(command) posts on the "command" channel so the mod can run it as the
player. Only works from a server-declared trusted origin; dropped otherwise.
useRunCommand() returns a stable callback.

- add runCommand + useRunCommand + tests
- bump to 1.6.0
@KoSHeroff
KoSHeroff merged commit fdec915 into main Jul 25, 2026
2 checks passed
@KoSHeroff
KoSHeroff deleted the feat/run-command branch July 25, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant