Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich command suggestion tooltips #2343

Closed
jpenilla opened this issue May 2, 2021 · 1 comment · Fixed by #2347
Closed

Rich command suggestion tooltips #2343

jpenilla opened this issue May 2, 2021 · 1 comment · Fixed by #2347
Labels
api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) status: pr pending system: command

Comments

@jpenilla
Copy link
Contributor

jpenilla commented May 2, 2021

In Brigadier, suggestions are able to have a Message tooltip, which will be shown to users when hovering over the suggestion. Minecraft's Component implements Message, so to get a Message from a Component is as simple as SpongeAdventure.asVanilla(Component).

This capability is not exposed to API however. In fact, when using the BrigadierCommandRegistrar, these tooltips will be lost: https://github.com/SpongePowered/Sponge/blob/0ca0e644f4e3b233f127ee936f5cfee29f0ba62c/src/main/java/org/spongepowered/common/command/registrar/BrigadierCommandRegistrar.java#L198-L199

A possible way to implement this would be replacing String based suggestion APIs with something like a Completion, which would be a holder for a string suggestion, and a nullable Component tooltip. The implementation can then decide how to deal with these Completions.

In addition it would be nice to expose an API for converting Component to Message, for plugin developers who want to use the Brigadier registrar.

@limbo-app limbo-app added the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label May 2, 2021
@jpenilla jpenilla changed the title Rich suggestion tooltips Rich command suggestion tooltips May 2, 2021
@dualspiral
Copy link
Contributor

A possible way to implement this would be replacing String based suggestion APIs with something like a Completion, which would be a holder for a string suggestion, and a nullable Component tooltip. The implementation can then decide how to deal with these Completions.

That'd be my way of doing it too.

In addition it would be nice to expose an API for converting Component to Message

Well, given Message is not in the API, no. If you were directly attaching to Brig using that registrar, you wouldn't need to do that anyway (though from what I remember, what you've linked to is just a way to fulfil the requirements of the registrar and that a completion via a stock Brig node is not going to go through that unless you pull it through that registrar).

Of course, I'm going to have to do something in impl to make that conversion, so anyone using Brig should just depend on the impl anyway because we make no guarantees that Brig is used in the background.

@dualspiral dualspiral added api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) system: command labels May 2, 2021
@limbo-app limbo-app removed the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label May 2, 2021
@dualspiral dualspiral linked a pull request May 3, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: 8 (u) version: 1.16 (unsupported since Oct 17th 2023) status: pr pending system: command
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants