Closed znepb closed 8 months ago
(internal ref)
Should be a trivial fix. ClaimKit isn't doing it's own startsWith check when adding suggestions to the SuggestionsBuilder, here: https://github.com/SwitchCraftCC/ClaimKit/blob/da28c414856499fb42a2cfa7a8ffd8c8fdaae058/src/main/java/com/kotahu/claimkit/commands/Trust.java#L40-L46
ClaimKit code:
private static CompletableFuture<Suggestions> suggestPlayers(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) {
ArrayList<String> l = UUIDs.getOnlinePlayerNames();
l.add(".public");
for (String a : l)
builder.suggest(a);
return builder.buildFuture();
}
I don't have a clue what's going on in lines 30-32 from the same file, but it probably has the same issue.
Example code doing it correctly from sc-essentials:
fun warpArgument(name: String = "name"): RequiredArgumentBuilder<ServerCommandSource, String>
= argument(name, word())
.suggests { _, builder ->
val remaining = builder.remainingLowerCase
Warps.warps()
.map { it.name }
.filter { it.lowercase().startsWith(remaining) }
.forEach { builder.suggest(it) }
builder.buildFuture()
}
And another correct example from CC:
public static <T> CompletableFuture<Suggestions> suggest(SuggestionsBuilder builder, Iterable<T> candidates, Function<T, String> toString) {
var remaining = builder.getRemaining().toLowerCase(Locale.ROOT);
for (var choice : candidates) {
var name = toString.apply(choice);
if (!name.toLowerCase(Locale.ROOT).startsWith(remaining)) continue;
builder.suggest(name);
}
return builder.buildFuture();
}
Fixed on 2024-03-02.
Describe the bug
When trusting a user (or any other ClaimKit command that involves "autocomplete",) the command will not properly autocomplete the message Example: Notice ".public" is selected, though "HerrKatzeGaming" should be
applies to other autocomplete brigadier things
To reproduce
Expected behavior
Intended behavior, in which
/w
will suggest the username you are typingRelevant log output
No response
Please confirm