Java Code Examples for com.mojang.brigadier.suggestion.SuggestionsBuilder#suggest()

The following examples show how to use com.mojang.brigadier.suggestion.SuggestionsBuilder#suggest() . 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: PointType.java    From Chimera with MIT License 6 votes vote down vote up
@Override
public void suggest(SuggestionsBuilder builder, String[] parts) {
    if (builder.getRemaining().isBlank()) {
        builder.suggest("~").suggest("~ ~").suggest("~ ~ ~");
        return;
    }
    
    var prefix = builder.getRemaining().charAt(0) == '^' ? '^' : '~';
    if (parts.length == 1) {
        builder.suggest(parts[0] + " " + prefix)
               .suggest(parts[0] + " " + prefix + " " + prefix);
        
    } else if (parts.length == 2) {
        builder.suggest(parts[0] + " " + parts[1] + " " + prefix);
    }
}
 
Example 2
Source File: AbstractSuggestionProvider.java    From BlueMap with MIT License 5 votes vote down vote up
@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 3
Source File: CommandAPIHandler.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
private CompletableFuture<Suggestions> getSuggestionsBuilder(SuggestionsBuilder builder, String[] array) {
	String remaining = builder.getRemaining().toLowerCase(Locale.ROOT);
	for (int i = 0; i < array.length; i++) {
		String str = array[i];
		if (str.toLowerCase(Locale.ROOT).startsWith(remaining)) {
			builder.suggest(str);
		}
	}
	return builder.buildFuture();
}
 
Example 4
Source File: PointType.java    From Chimera with MIT License 5 votes vote down vote up
@Override
public void suggest(SuggestionsBuilder builder, String[] parts) {
    if (builder.getRemaining().isBlank()) {
        builder.suggest("~").suggest("~ ~");
        
    } else if (parts.length == 1) {
        var prefix = builder.getRemaining().charAt(0) == '^' ? '^' : '~';
        builder.suggest(parts[0] + " " + prefix);
    }
}
 
Example 5
Source File: BoolArgumentType.java    From brigadier with MIT License 5 votes vote down vote up
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) {
    if ("true".startsWith(builder.getRemaining().toLowerCase())) {
        builder.suggest("true");
    }
    if ("false".startsWith(builder.getRemaining().toLowerCase())) {
        builder.suggest("false");
    }
    return builder.buildFuture();
}
 
Example 6
Source File: HexColorArgument.java    From BoundingBoxOutlineReloaded with MIT License 4 votes vote down vote up
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
    if (builder.getRemaining().length() == 0) builder.suggest("#");
    return builder.buildFuture();
}