LapisBlue / Pore

(Archive, not actively maintained) Run existing Bukkit plugins on Sponge natively
https://docs.lapis.blue/pore/
Other
61 stars 23 forks source link

Enhancement/commands #16

Closed Lamp-Post closed 9 years ago

Lamp-Post commented 9 years ago

With this PR commands from Bukkit plugins are getting registered to Sponge. So you get information on them, with the help command. You also do not get an error anymore saying it is an unknown command. I also changed that the commands are only being passed to the pore server, when it is a command used by a Bukkit plugin.

caseif commented 9 years ago

I'm unable to replicate the functionality you've described in regard to the /help command on a local Sponge server. Is this PR tested?

stephan-gh commented 9 years ago

I think the better way to implement this is to register the commands in Bukkit directly in Sponge's command service and remove the CommandEvent. That way it will also work when called through the CommandCallable directly.

Lamp-Post commented 9 years ago

@caseif I've tested it, and noticed it too. But this is because it is not yet implemented by Sponge, it is in the SpongeAPI. @Minecrell I've also thought of that, the only problem I came across was that I only get the arguments of the command, not the command itself. So I cannot pass it on to Pore.

stephan-gh commented 9 years ago

I guess you would need to create a custom CommandMap implementation that forwards everything to Sponge's CommandService.

Lamp-Post commented 9 years ago

I mean, when the command is being called, this method in CommandBase is called:

public Optional<CommandResult> process(CommandSource source, String arguments) throws CommandException

the command is being called, but I only get the source of the command and its arguments not the command itself So I do not know which command is being called

Lamp-Post commented 9 years ago

Nevermind I can also store the command itself in CommandBase for every command when it is being registered

jamierocks commented 9 years ago

You can find the Lapis code style for both Eclipse and IntelliJ in https://github.com/LapisBlue/Commons/tree/master/etc .

stephan-gh commented 9 years ago

@Lamp-Post Is this ready to merge?

Lamp-Post commented 9 years ago

@Minecrell yes it is

jamierocks commented 9 years ago

@Minecrell ready if you don't mind having no tab-complete support...

stephan-gh commented 9 years ago

After looking into it some more, I decided to implement this a little bit different. Basically, your way has the following problems:

The custom PoreCommandMap lets Sponge handle the complete command handling which should be more reliable in most cases. Thanks a lot for your contribution anyway!