I would like an easy way to implement commands, with each command being in its own class (I think I’ll make a separate package for these). So I derived an idea from SpongeAPI- you have to use the @Plugin annotation to get your plugin even viewed by Sponge. Can I make my own @spongeCommand annotation; create classes using the annotation then create something to look for all the @spongeCommand annotations, to then run the classes with the annotation?
Actually, this question might help better. Can someone explain to me (in a basic, probably short) how Sponge deals with the annotation? Or, link me to something, on how it works?
if your only goal is to have commands in separate classes you don’t need to go through so much trouble, this is possible within the sponge api itself.
Command Class
public class TestCommand implements CommandExecutor {
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
//do stuff
}
}
Registering command in main class
In reply to RysingDragon, That won’t work for me. I would still have to have a list of commands in a designated file, or put it all in the same area of onInit(), because of the “TestCommand()” part. I would need to hard-code/know the method, wouldn’t I?