Don't suggest opts that have already been added for dump command

This commit is contained in:
Konicai 2023-09-05 04:24:18 -04:00
parent bdbef04e8e
commit cdf06ce350
No known key found for this signature in database
GPG Key ID: 710D09287708C823
1 changed files with 16 additions and 3 deletions

View File

@ -25,7 +25,6 @@
package org.geysermc.geyser.command.defaults;
import cloud.commandframework.Command;
import cloud.commandframework.CommandManager;
import cloud.commandframework.arguments.standard.StringArrayArgument;
import cloud.commandframework.context.CommandContext;
@ -45,6 +44,7 @@ import org.geysermc.geyser.util.WebUtils;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DumpCommand extends GeyserCommand {
@ -69,8 +69,21 @@ public class DumpCommand extends GeyserCommand {
}
private StringArrayArgument<GeyserCommandSource> createArgument() {
// todo suggestions might be broken
return StringArrayArgument.optional(ARGUMENTS, (context, input) -> SUGGESTIONS);
return StringArrayArgument.optional(ARGUMENTS, (context, currentInput) -> {
// currentInput only provides the word currently being typed, so it's useless for checking the previous ones
List<String> input = context.getRawInput();
if (input.size() <= 2) {
return SUGGESTIONS; // only `geyser dump` was typed (2 literals)
}
// the rest of the input after `geyser dump` is for this argument
input = input.subList(2, input.size());
// don't suggest any words they have already typed
List<String> suggestions = new ArrayList<>(SUGGESTIONS);
suggestions.removeAll(input);
return suggestions;
});
}
@Override