Skip to content

Stop renaming sub-commands to the alias a player typed (#3075) - #3076

Merged
tastybento merged 1 commit into
developfrom
fix/3075-subcommand-label-mutation
Sep 5, 2026
Merged

tastybento merged 1 commit into
developfrom
fix/3075-subcommand-label-mutation

Conversation

@tastybento

Copy link
Copy Markdown
Member

Fixes #3075

What was happening

/ob go has the aliases home and h. CompositeCommand.getCommandFromArgs walked the typed arguments and called setLabel(arg) on the shared sub-command object, so after any player typed /ob h the go command's label became h for everyone. Tab completion advertises sub-commands by getLabel(), which is why the reporter saw /ob h where /ob go should be, and why it "reverted" seemingly at random: it followed whichever alias anyone had used most recently.

Brigadier registration (3.22.0) made this much more visible. The greedy-argument suggestion provider calls tabComplete on every keystroke, so merely typing /ob h was enough to rename the command. It also broke the registrar's literal de-duplication, which compares sub.getLabel() against the advertised literal names, so the alias was pushed to clients as an extra suggestion.

The same mutated label leaked into ConfirmableCommand (confirmations are keyed by label) and DefaultHelpCommand.

The fix

execute() already derives the typed alias from the args array and hands it to call(user, cmdLabel, cmdArgs), so the mutation was redundant. This PR removes the setLabel(arg) call and adds SubCommandAliasLabelTest, which:

  • tab-completes via h and asserts the label stays go and the completion list offers go, not h or home
  • executes via home and h and asserts the sub-command still receives the typed alias while its own label and usage stay go

Not changed, on purpose: the home/h aliases and the island.home permission name the reporter suggested removing or renaming. They are long-standing public behaviour and the display was the only thing wrong.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QTSR5y1ScxFzCqcXiAXXFT

CompositeCommand.getCommandFromArgs called setLabel(arg) on the shared
sub-command object while walking the typed arguments. After any player
used /island h, every other player's tab completion advertised "h" in
place of "go", and it flipped again whenever someone typed another alias.
Brigadier made this far more visible because tabComplete now runs on
every keystroke, so merely typing the alias was enough.

execute() already derives the typed alias from the args array and passes
it to call(), so the mutation was redundant. Drop it and add a
regression test.

Fixes #3075

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QTSR5y1ScxFzCqcXiAXXFT
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@tastybento
tastybento merged commit 2aee5de into develop Sep 5, 2026
3 checks passed
@tastybento
tastybento deleted the fix/3075-subcommand-label-mutation branch September 5, 2026 22:14
@tastybento tastybento mentioned this pull request Sep 6, 2026
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.

Strange command display.

1 participant