Registering aliases?
I was wondering if it's possible to register aliases to certain commands using the commodore file format. Right now I have something like this:
InputStream is = //...
LiteralCommandNode<?> commandNode = CommodoreFileFormat.parse(is);
CommandNode hologramCmd = commandNode.getChild("hologram");
LiteralCommandNode child = LiteralArgumentBuilder.literal("holo")
.redirect(hologramCmd)
.build();
commandNode.addChild(child);
commodore.register(command, commandNode);
which is obviously not that great since I'd have to write something like shown above for all aliases. Is there a better solution for this?
Using Commodore#register(Command, LiteralCommandNode) will automatically register the data for all aliases of the command.
The code for that is here: https://github.com/lucko/commodore/blob/1c1b6287847cf66beea31efa5e293a5316ad92b3/src/main/java/me/lucko/commodore/CommodoreImpl.java#L166-L171
https://github.com/lucko/commodore/blob/1c1b6287847cf66beea31efa5e293a5316ad92b3/src/main/java/me/lucko/commodore/CommodoreImpl.java#L201-L207
So if you're using that, there should be no more effort required on your part. :)
Yeah, all the commands using Commodore#register. However, in my case I only have 1 root command, and some subcommands. What I'm trying to achieve is to have /rootcommand subcommand <some args> and /rootcommand sub <some args> where subcommand and sub are aliases, and the two would do the same. :C
I think the suggestion here is to add the ability to define command redirection in the commodore file format.
A suggestion for the commodore file format including a redirection could look like this:
your_command {
hologram {
// some args
}
holo redirect your_command hologram;
}
That'd be cool!