This would help creating OrphanCommand with @DefaultFor annotation.
We can easily reference like: \@DefaultFor("~"), and it would take parent path.
For example:
@Command("simple")
public class SimpleCommand {
@DefaultFor("~")
public void onCommand(){
// executed when /simple dispatched
}
@DefaultFor({"~", "test"}) // I think it will behavior like subcommand
public void onTestCommand(){
// executed when /simple test dispatched
}
@DefaultFor({"too","~"}) // Its like subcommand, but revesed
public void onTooCommand(){
// executed when /too simple dispatched
}
}
And yes, like that command will be invalid and throw
@Command("simple")
public class SimpleCommand {
@DefaultFor("~")
public void onCommand(){
// executed when /simple dispatched
}
@DefaultFor({"~", "test"}) // I think it will behavior like subcommand
public void onTestCommand(){
// executed when /simple test dispatched
}
@DefaultFor({"too","~"}) // Its like subcommand, but reversed
public void onTooCommand(){
// executed when /too simple dispatched
}
@DefaultFor("simple")
public void onInvalidCommand(){
// executed when /simple dispatched
}
}
Exception:
Exception in thread "main" java.lang.IllegalArgumentException: Category 'simple' has more than one default action! (public void SimpleCommand.onCommand() and public void SimpleCommand.onInvalidCommand())
at revxrsal.commands.core.CommandExecutable.parent(CommandExecutable.java:158)
at revxrsal.commands.core.CommandParser.lambda$parse$4(CommandParser.java:177)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at revxrsal.commands.core.CommandParser.parse(CommandParser.java:152)
at revxrsal.commands.core.CommandParser.parse(CommandParser.java:106)
at revxrsal.commands.core.BaseCommandHandler.register(BaseCommandHandler.java:188)
This would help creating OrphanCommand with @DefaultFor annotation. We can easily reference like: \@DefaultFor("~"), and it would take parent path.
For example:
And yes, like that command will be invalid and throw
Exception: