Making a custom parser that accepts a subtype of your sender type (in my case org.bukkit.entity.Player of org.bukkit.command.CommandSender) is very useful as to automatically utilize existing error infrastructure (specifically the TerminalConsoleCommandSender is not allowed to execute that command. Must be of type Player message).
Currently, the existing ParserRegistry#registerParser(ParserDescriptor) method does not allow type narrowing and requires an unchecked cast to allow it to compile.
Example in Kotlin:
manager.parserRegistry().registerParser(ParserDescriptor.of(MineParser() as ArgumentParser<CommandSender, Mine>, Mine::class.java))
I was told by @jpenilla that there could be a method added that gives a view of the parser registry for subtypes specifically, so that this can be validated correctly. Here is the Discord message where this was mentioned.
Making a custom parser that accepts a subtype of your sender type (in my case
org.bukkit.entity.Player
oforg.bukkit.command.CommandSender
) is very useful as to automatically utilize existing error infrastructure (specifically theTerminalConsoleCommandSender is not allowed to execute that command. Must be of type Player
message).Currently, the existing
ParserRegistry#registerParser(ParserDescriptor)
method does not allow type narrowing and requires an unchecked cast to allow it to compile.Example in Kotlin:
I was told by @jpenilla that there could be a method added that gives a view of the parser registry for subtypes specifically, so that this can be validated correctly. Here is the Discord message where this was mentioned.