| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Added a new option: skipListValidation
There was a problem hiding this comment.
A few things I noticed that I believe should be addressed.
Otherwise I guess I like this concept. It is a fairly niche feature but I don't see a reason why it shouldn't be added.
Sorry, something went wrong.
|
|
||
| // If the argument's value is in the list of values, include it | ||
| List<T> list = new ArrayList<>(); | ||
| if (skipListValidation) return list; |
There was a problem hiding this comment.
I am unsure about this check being here. I mean, despite not checking if only valid values were given, you probably still would want access to the given list in the argument.
I'd suggest using the boolean to disable the exceptions from being thrown instead of using it to return an empty list.
Sorry, something went wrong.
There was a problem hiding this comment.
I was originally doing it this way but then discovered that the list was always empty so after some testing I decided to just have it return early instead.
Sorry, something went wrong.
There was a problem hiding this comment.
In this case, an alternate way of parsing this argument would have to be created. The list returned should contain the values provided by the user. I am not willing to say that users will have to keep track of their own list in order to validate results or something because returning an empty list is basically not acceptable.
Sorry, something went wrong.
| */ | ||
| public ListArgument<T> buildGreedy() { | ||
| return new ListArgument<>(nodeName, delimiter, allowDuplicates, supplier, mapper); | ||
| return new ListArgument<>(nodeName, delimiter, allowDuplicates, supplier, mapper, skipListValidation); |
There was a problem hiding this comment.
This option should not only be used here. If it should be added, the ListTextArgument should also be able to work with this option.
Sorry, something went wrong.
|
Just a note that the command you implemented seems to have similar functionality to the FlagsArgument proposed by #483. Development on that is currently in progress on the dev/command-build-rewrite branch 22c2ffa. Also, dev/argument-exceptions #476 currently provides the API for developers to manually suppress the exceptions thrown when the CommandAPI parses the ListArgument. |
Sorry, something went wrong.
slight code change
|
This latest iteration doesn't work. I tested this command: new CommandAPICommand("test")
.withArguments(new ListArgumentBuilder<String>("list")
.skipListValidation(true)
.withList("test")
.withStringMapper()
.buildGreedy()
)
.executesPlayer(info -> {
List<String> list = (List<String>) info.args().get("list");
info.sender().sendMessage(Component.text().content(list.toString()).build());
})
.register();I then executed this command: /test hello test police The output I got was [test], the expected result would be [hello, test, police] if the validation is skipped. |
Sorry, something went wrong.
Yeah it's not the most intuitive since the list basically is only good for suggestions. .executes(CommandExecutor { sender, args -> processCmd(sender, args) })
# ...
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.withList { info -> buildTabSuggestions(info) }
.withStringMapper()
.buildGreedy()
val values = args.rawArgsMap["values"]
val args = splitStringWithQuotes(values) # split into array and treat quotes as one elementHere's how I used it https://github.com/ArcanePlugins/LevelledMobs/blob/4.0.0-dev/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/commands/subcommands/SummonSubcommand.kt#L56 |
Sorry, something went wrong.
|
Nope, that's not how it's going to work when merged; the List returned has to contain every relevant value. As I said, it would be best to have a separate parsing method when list validation is skipped. |
Sorry, something went wrong.
|
I'll probably just cancel this PR and wait for FlagsArgument proposed by #483 since it likely works better and is more intuitive. |
Sorry, something went wrong.
I mean, do what you want to do, but again, this, despite being a really niche feature, can be useful. It just needs a bit more attention since there are expectations when using the list. |
Sorry, something went wrong.
Also, not true. The list, if validations are not skipped, provides the player or any other command executor with a list of options. The items in the suggestion list are there to tell the user the valid options. |
Sorry, something went wrong.
|
@stumper66 |
Sorry, something went wrong.
|
Cancelling the PR |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Added a new option: skipListValidation
This allows me to use ListArgumentBuilder for complex tab suggestions and simply passing all input so I can do my own validation.
This allowed me to create this command: https://youtu.be/q03_paw9Vzk