Java Code Examples for com.mojang.brigadier.suggestion.Suggestions#empty()
The following examples show how to use
com.mojang.brigadier.suggestion.Suggestions#empty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityArgumentType_1_12_2.java From multiconnect with MIT License | 6 votes |
@SuppressWarnings("unchecked") @Override public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { if (!(context.getSource() instanceof CommandSource)) return builder.buildFuture(); StringReader reader = new StringReader(builder.getInput()); reader.setCursor(builder.getStart()); CompletableFuture<Suggestions> playerCompletions; if ((reader.canRead() && reader.peek() == '@') || !suggestPlayerNames) { playerCompletions = Suggestions.empty(); } else { playerCompletions = ((CommandSource) context.getSource()).getCompletions((CommandContext<CommandSource>) context, builder.restart()); } EntitySelectorParser parser = new EntitySelectorParser(reader, singleTarget, playersOnly); try { parser.parse(); } catch (CommandSyntaxException ignore) { } CompletableFuture<Suggestions> selectorCompletions = parser.suggestor.apply(builder.restart()); return CompletableFuture.allOf(playerCompletions, selectorCompletions) .thenCompose(v -> UnionArgumentType.mergeSuggestions(playerCompletions.join(), selectorCompletions.join())); }
Example 2
Source File: ForgeClientSparkPlugin.java From spark with GNU General Public License v3.0 | 6 votes |
@Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<ISuggestionProvider> context, SuggestionsBuilder builder) throws CommandSyntaxException { String chat = context.getInput(); String[] split = chat.split(" "); if (split.length == 0 || (!split[0].equals("/sparkc") && !split[0].equals("/sparkclient"))) { return Suggestions.empty(); } String[] args = Arrays.copyOfRange(split, 1, split.length); return CompletableFuture.supplyAsync(() -> { for (String suggestion : this.platform.tabCompleteCommand(new ForgeCommandSender(this.minecraft.player, this), args)) { builder.suggest(suggestion); } return builder.build(); }); }
Example 3
Source File: FabricClientSparkPlugin.java From spark with GNU General Public License v3.0 | 6 votes |
@Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException { String[] split = context.getInput().split(" "); if (split.length == 0 || (!split[0].equals("/sparkc") && !split[0].equals("/sparkclient"))) { return Suggestions.empty(); } String[] args = Arrays.copyOfRange(split, 1, split.length); return CompletableFuture.supplyAsync(() -> { for (String suggestion : this.platform.tabCompleteCommand(new FabricCommandSender(this.minecraft.player, this), args)) { builder.suggest(suggestion); } return builder.build(); }); }
Example 4
Source File: AbstractSuggestionProvider.java From BlueMap with MIT License | 5 votes |
@Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<S> context, SuggestionsBuilder builder) throws CommandSyntaxException { Collection<String> possibleValues = getPossibleValues(); if(possibleValues.isEmpty()) return Suggestions.empty(); String remaining = builder.getRemaining().toLowerCase(); for (String str : possibleValues) { if (str.toLowerCase().startsWith(remaining)) { builder.suggest(str = StringArgumentType.escapeIfRequired(str)); } } return builder.buildFuture(); }
Example 5
Source File: UnionArgumentType.java From multiconnect with MIT License | 5 votes |
static CompletableFuture<Suggestions> mergeSuggestions(Suggestions a, Suggestions b) { if (a.isEmpty() && b.isEmpty()) return Suggestions.empty(); if (a.isEmpty()) return CompletableFuture.completedFuture(b); if (b.isEmpty()) return CompletableFuture.completedFuture(a); Set<Suggestion> suggestions = new LinkedHashSet<>(); suggestions.addAll(a.getList()); suggestions.addAll(b.getList()); return CompletableFuture.completedFuture(new Suggestions(StringRange.encompassing(a.getRange(), b.getRange()), new ArrayList<>(suggestions))); }
Example 6
Source File: ForgeServerSparkPlugin.java From spark with GNU General Public License v3.0 | 5 votes |
@Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException { String[] args = processArgs(context); if (args == null) { return Suggestions.empty(); } ServerPlayerEntity player = context.getSource().asPlayer(); return CompletableFuture.supplyAsync(() -> { for (String suggestion : this.platform.tabCompleteCommand(new ForgeCommandSender(player, this), args)) { builder.suggest(suggestion); } return builder.build(); }); }
Example 7
Source File: FabricServerSparkPlugin.java From spark with GNU General Public License v3.0 | 5 votes |
@Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException { String[] args = processArgs(context); if (args == null) { return Suggestions.empty(); } ServerPlayerEntity player = context.getSource().getPlayer(); return CompletableFuture.supplyAsync(() -> { for (String suggestion : this.platform.tabCompleteCommand(new FabricCommandSender(player, this), args)) { builder.suggest(suggestion); } return builder.build(); }); }
Example 8
Source File: NMS_1_16_R1.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public SuggestionProvider getSuggestionProvider(SuggestionProviders provider) { switch (provider) { case FUNCTION: return (context, builder) -> { CustomFunctionData functionData = getCLW(context).getServer().getFunctionData(); ICompletionProvider.a(functionData.g(), builder, "#"); return ICompletionProvider.a(functionData.f(), builder); }; case RECIPES: return CompletionProviders.b; case SOUNDS: return CompletionProviders.c; case ADVANCEMENTS: return (cmdCtx, builder) -> { Collection<Advancement> advancements = ((CommandListenerWrapper) cmdCtx.getSource()).getServer() .getAdvancementData().getAdvancements(); return ICompletionProvider.a(advancements.stream().map(Advancement::getName), builder); }; case LOOT_TABLES: return (context, builder) -> { LootTableRegistry lootTables = getCLW(context).getServer().getLootTableRegistry(); return ICompletionProvider.a(lootTables.a(), builder); }; case BIOMES: return CompletionProviders.d; case ENTITIES: return CompletionProviders.e; default: return (context, builder) -> Suggestions.empty(); } }
Example 9
Source File: NMS_1_14.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public SuggestionProvider getSuggestionProvider(SuggestionProviders provider) { switch (provider) { case FUNCTION: return (context, builder) -> { CustomFunctionData functionData = getCLW(context).getServer().getFunctionData(); ICompletionProvider.a(functionData.g().a(), builder, "#"); return ICompletionProvider.a(functionData.c().keySet(), builder); }; case RECIPES: return CompletionProviders.b; case SOUNDS: return CompletionProviders.c; case ADVANCEMENTS: return (cmdCtx, builder) -> { Collection<Advancement> advancements = ((CommandListenerWrapper) cmdCtx.getSource()).getServer() .getAdvancementData().b(); return ICompletionProvider.a(advancements.stream().map(Advancement::getName), builder); }; case LOOT_TABLES: return (context, builder) -> { LootTableRegistry lootTables = getCLW(context).getServer().getLootTableRegistry(); return ICompletionProvider.a(lootTables.a(), builder); }; case ENTITIES: return CompletionProviders.d; case BIOMES: default: return (context, builder) -> Suggestions.empty(); } }
Example 10
Source File: NMS_1_15.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public SuggestionProvider getSuggestionProvider(SuggestionProviders provider) { switch (provider) { case FUNCTION: return (context, builder) -> { CustomFunctionData functionData = getCLW(context).getServer().getFunctionData(); ICompletionProvider.a(functionData.h().a(), builder, "#"); return ICompletionProvider.a(functionData.c().keySet(), builder); }; case RECIPES: return CompletionProviders.b; case SOUNDS: return CompletionProviders.c; case ADVANCEMENTS: return (cmdCtx, builder) -> { Collection<Advancement> advancements = ((CommandListenerWrapper) cmdCtx.getSource()).getServer() .getAdvancementData().getAdvancements(); return ICompletionProvider.a(advancements.stream().map(Advancement::getName), builder); }; case LOOT_TABLES: return (context, builder) -> { LootTableRegistry lootTables = getCLW(context).getServer().getLootTableRegistry(); return ICompletionProvider.a(lootTables.a(), builder); }; case ENTITIES: return CompletionProviders.d; case BIOMES: default: return (context, builder) -> Suggestions.empty(); } }
Example 11
Source File: NMS_1_14_4.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public SuggestionProvider getSuggestionProvider(SuggestionProviders provider) { switch (provider) { case FUNCTION: return (context, builder) -> { CustomFunctionData functionData = getCLW(context).getServer().getFunctionData(); ICompletionProvider.a(functionData.h().a(), builder, "#"); return ICompletionProvider.a(functionData.c().keySet(), builder); }; case RECIPES: return CompletionProviders.b; case SOUNDS: return CompletionProviders.c; case ADVANCEMENTS: return (cmdCtx, builder) -> { Collection<Advancement> advancements = ((CommandListenerWrapper) cmdCtx.getSource()).getServer().getAdvancementData().a(); return ICompletionProvider.a(advancements.stream().map(Advancement::getName), builder); }; case LOOT_TABLES: return (context, builder) -> { LootTableRegistry lootTables = getCLW(context).getServer().getLootTableRegistry(); return ICompletionProvider.a(lootTables.a(), builder); }; case ENTITIES: return CompletionProviders.d; case BIOMES: default: return (context, builder) -> Suggestions.empty(); } }
Example 12
Source File: NMS_1_14_3.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public SuggestionProvider getSuggestionProvider(SuggestionProviders provider) { switch (provider) { case FUNCTION: return (context, builder) -> { CustomFunctionData functionData = getCLW(context).getServer().getFunctionData(); ICompletionProvider.a(functionData.h().a(), builder, "#"); return ICompletionProvider.a(functionData.c().keySet(), builder); }; case RECIPES: return CompletionProviders.b; case SOUNDS: return CompletionProviders.c; case ADVANCEMENTS: return (cmdCtx, builder) -> { Collection<Advancement> advancements = ((CommandListenerWrapper) cmdCtx.getSource()).getServer().getAdvancementData().a(); return ICompletionProvider.a(advancements.stream().map(Advancement::getName), builder); }; case LOOT_TABLES: return (context, builder) -> { LootTableRegistry lootTables = getCLW(context).getServer().getLootTableRegistry(); return ICompletionProvider.a(lootTables.a(), builder); }; case ENTITIES: return CompletionProviders.d; case BIOMES: default: return (context, builder) -> Suggestions.empty(); } }
Example 13
Source File: LiteralCommandNode.java From brigadier with MIT License | 5 votes |
@Override public CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) { if (literal.toLowerCase().startsWith(builder.getRemaining().toLowerCase())) { return builder.suggest(literal).buildFuture(); } else { return Suggestions.empty(); } }
Example 14
Source File: RootCommandNode.java From brigadier with MIT License | 4 votes |
@Override public CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) { return Suggestions.empty(); }
Example 15
Source File: ArgumentType.java From brigadier with MIT License | 4 votes |
default <S> CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) { return Suggestions.empty(); }