SpongePowered / SpongeDocs

Documentation for Sponge and its Implementations
Creative Commons Attribution Share Alike 4.0 International
110 stars 116 forks source link

Add information on how to override / underride vanilla commands #197

Open ryantheleach opened 9 years ago

ryantheleach commented 9 years ago

And when to register commands.

https://github.com/SpongePowered/SpongeDocs/pull/183#issuecomment-99098988

If there is an equivalent of a command pre processor for scripting plugins such as skript or CommandHelper it should also be mentioned that it shouldn't be used for general command registration (if possible) but only to intercept commands in general.

boformer commented 9 years ago

By the way, the recommended event to register commands should be set to InitializationEvent:

http://docs.spongepowered.org/en/plugin/basics/commands.html#the-command-service

ryantheleach commented 8 years ago

Can commands be registered later / dynamically? or is there a hard cut off?

boformer commented 8 years ago

There is nothing that would prevent that. It was one of the goals of Sponge to provide a dynamic command system.

ryantheleach commented 8 years ago

So registering a command returns an optional commandmapping, I just found out that sponge automatically registers disambiguation aliases with the plugin name as a prefix, so it's extremely unlikely that command registration would return absent. The only situation I can imagine it happening in, is if the same command were somehow registered twice. In which case it's almost certainly an error.

ST-DDT commented 6 years ago

@ryantheleach AFAICT the issues that this issue is about are:

Refs:

ryantheleach commented 6 years ago

It was originally just about precedence vs Vanilla, and the effects of the order that commands are registered in. I mainly made this issue because I would have been searching for the information back in 2015, and being unable to find the answer.

It's been a long time since then, so the specific behavior I may have been talking about may have been a bug.

But If I recall correctly it used to be possible to register your command before vanilla did, and that would influence who 'won' the command for players, and that was confusing. At the time I thought it was intended behavior, now I'm not so sure, especially considering the disambiguation aliases.

I also used to make the 'mistake' of not realizing just how early preinit was.