Issue with Registering Command

Hi All,

I was porting my plugin from Bukkit, and I was having an issue with registering commands. I tried the following:

As per the docs:

CommandService cmdService = game.getCommandDispatcher();		
cmdService.register(myPlugin, new MyCommand(), "command", "commandAlias");

As per [this example][1]:

Injector injector = Guice.createInjector(new DefaultModule(game));
CommandService cmdService = game.getCommandDispatcher();
cmdService.register(myPlugin, injector.getInstance(MyCommand.class), "command", "commandAlias");

Neither of these worked. Additionally, I also printed out the results of CommandService.getCommands(), which outputted the expected results of the commands I registered. However, the server still tells me “Unknown command. Try /help for a list of commands”

Any ideas?

Thanks,
-Zirconium
[1]: https://github.com/sk89q/SpongeExample/tree/master/src/main/java/example

This may not be implementedd yet. I’ll take a look :stuck_out_tongue:

EDIT: Doesn’t look like that is implemented… (Unless I’m a complete idiot, which I am anyways…)

Commands have worked fine for me. Here’s a sample code that registers a command “test” that calls handleTestCommand if a player enters /test
http://pastebin.com/72M1Hbhs
Arguments are then split up and handled accordingly.

Are you currently using the most recent implementation?

I have some working command registration code here: SpongePlots/SpongePlots.java at master · kenneaal/SpongePlots · GitHub along with SpongePlots/Commands.java at master · kenneaal/SpongePlots · GitHub

Runs on latest API.

Both of these look nearly identical to my setup… Not sure what’s wrong

Hop on #spongedev and ask there, bring GISTs. :wink:

If you were testing with a build from yesterday, the command execution through the command service was broken as of this commit:

I’ve fixed this now so it should work fine if this was the problem. Sorry for the confusion, I should have tested this more intensively before pushing it to the repo. :smile:

It works great now! Thanks for the quick fix.