Stop renaming sub-commands to the alias a player typed (#3075) - #3076
Merged
Merged
Conversation
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
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #3075
What was happening
/ob gohas the aliaseshomeandh.CompositeCommand.getCommandFromArgswalked the typed arguments and calledsetLabel(arg)on the shared sub-command object, so after any player typed/ob hthe go command's label becamehfor everyone. Tab completion advertises sub-commands bygetLabel(), which is why the reporter saw/ob hwhere/ob goshould 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
tabCompleteon every keystroke, so merely typing/ob hwas enough to rename the command. It also broke the registrar's literal de-duplication, which comparessub.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) andDefaultHelpCommand.The fix
execute()already derives the typed alias from the args array and hands it tocall(user, cmdLabel, cmdArgs), so the mutation was redundant. This PR removes thesetLabel(arg)call and addsSubCommandAliasLabelTest, which:hand asserts the label staysgoand the completion list offersgo, nothorhomehomeandhand asserts the sub-command still receives the typed alias while its own label and usage staygoNot changed, on purpose: the
home/haliases and theisland.homepermission 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