tutorial:commands
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:commands [2020/06/14 04:41] – Link to new suggestions page i509vcb | tutorial:commands [2020/06/14 04:53] – Populate advanced concepts table i509vcb | ||
---|---|---|---|
Line 216: | Line 216: | ||
Below are links to the articles about more complex concepts used in brigadier. | Below are links to the articles about more complex concepts used in brigadier. | ||
- | ^ Page | + | ^ Page |
- | | [[tutorials: | + | | [[tutorials: |
+ | | [[tutorials: | ||
+ | | [[tutorials: | ||
+ | | [[tutorials: | ||
+ | | [[tutorials: | ||
+ | | [[tutorials: | ||
- | **TODO:** Sections are being moved to sub categories and will be added here as they are moved | + | **TODO:** Sections are being moved to sub categories and will be added to their respective articles |
- | + | ||
- | ===== Suggestions ===== | + | |
- | + | ||
- | Suggestions can be provided | + | |
- | < | + | |
- | SUMMONABLE_ENTITIES | + | |
- | AVAILIBLE_SOUNDS | + | |
- | ALL_RECIPES | + | |
- | ASK_SERVER | + | |
- | </ | + | |
- | + | ||
- | Loot tables specify | + | |
- | + | ||
- | The example below is a dynamically changing SuggestionProvider that lists several words for a StringArgumentType to demonstrate how it works: | + | |
- | <code java [enable_line_numbers=" | + | |
- | public static SuggestionProvider< | + | |
- | return (ctx, builder) -> getSuggestionsBuilder(builder, | + | |
- | } | + | |
- | + | ||
- | private static CompletableFuture< | + | |
- | String remaining = builder.getRemaining().toLowerCase(Locale.ROOT); | + | |
- | + | ||
- | if(list.isEmpty()) { // If the list is empty then return no suggestions | + | |
- | return Suggestions.empty(); | + | |
- | } | + | |
- | + | ||
- | for (String str : list) { // Iterate through the supplied list | + | |
- | if (str.toLowerCase(Locale.ROOT).startsWith(remaining)) { | + | |
- | builder.suggest(str); | + | |
- | } | + | |
- | } | + | |
- | return builder.buildFuture(); | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | The SuggestionProvider is a functional interface that returns a CompletableFuture containing a list of suggestions. These suggestions are sent to client | + | |
- | + | ||
- | Though remember these are suggestions. The inputted command may not contain an argument you suggested so arguments are parsed without consideration for suggestions. | + | |
- | + | ||
- | To use the suggestion you would append it right after the argument you want to suggest possible arguments for. This can be any argument and the normal client side exception popups will still work. Note this cannot be applied to literals. | + | |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | argument(argumentName, | + | |
- | .suggests(CompletionProviders.suggestedStrings()) | + | |
- | | + | |
- | </ | + | |
===== Requirements ===== | ===== Requirements ===== |
tutorial/commands.txt · Last modified: 2024/02/23 14:22 by allen1210