-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: Document custom argument suggestions #536
base: main
Are you sure you want to change the base?
Conversation
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
/mergeable |
61c7327
to
5277a45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The index page still says this page is a WIP though. Needs updating :)
I mean, I didn't even mention this specific page in the WIP section. But I did add it now. Anything else? |
|
||
This example obviously does not suggest anything, as we haven't added any suggestions yet. | ||
|
||
## The `SuggestionBuilder` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo SuggestionsBuilder
| getRemainingLowerCase() | asumm13text | The input for the current argument, lowercased | | ||
|
||
### Suggestions | ||
The following overloads of the `SuggestionBuilder#suggest` method add values that will be send to the client as argument suggestions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same typo here
|
||
// Retrieve our argument values | ||
final ItemStack item = ctx.getArgument("item", ItemStack.class); | ||
final int amount = IntegerArgumentType.getInteger(ctx, "stacksize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount is better for the argument name i think
|
||
// Set the item's amount and give it to the player | ||
item.setAmount(amount); | ||
player.getInventory().setItem(player.getInventory().firstEmpty(), item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be better using the new Player#give method to handle stack size properly. But if you think it's too complicated the first empty slot could be saved in a separate var.
Closes #527.
Extending onto the Brigadier documentation, here I have documented the
suggests
method of aRequiredArgumentBuilder
.