Add Option for Automatic Exception on Empty EntitySelectorArgument Lists
learliet opened this issue · comments
Description
There should be an option available when utilizing the EntitySelectorArgument
to trigger an exception automatically when the resulting list is empty. This behavior mirrors the default implementation where argument.entity.notfound.entity or argument.entity.notfound.player is respectively returned.
Expected code
val myCommand = CommandAPICommand("myCommand")
.withArguments(EntitySelectorArgument.ManyPlayers("players", false)) // allowEmpty flag
.executes(CommandExecutor { sender, args ->
// automatically returns "argument.entity.notfound.player" if empty
val players = args[0] as List<Player>
// [...]
})
Extra details
No response
I like this idea, and it should be fairly trivial to implement. In our existing multiple entity selector code, we have this:
In this implementation, we catch the exception when the list of entities would be empty and instead return an empty array. Adding a parameter to allow this exception to bubble up should be available as an option.
It would be nice to get this implemented for our next release given how simple this is to implement.
Implemented in version 9.4.0.