SpongeDocs
SpongeDocs copied to clipboard
Add information on how to override / underride vanilla commands
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.
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
Can commands be registered later / dynamically? or is there a hard cut off?
There is nothing that would prevent that. It was one of the goals of Sponge to provide a dynamic command system.
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.
@ryantheleach AFAICT the issues that this issue is about are:
-
plugin -> commands -> creating: Mention during which event the commands should be registered (
GameInitializationEvent
) / add link toCommandManager
docs - plugin -> commands -> creating: Mention disambiguation aliases
- plugin -> commands: Mention dynamic command (un)registration
- server -> management: Configure precedence of commands with the same alias
Refs:
- https://docs.spongepowered.org/stable/en/plugin/commands/creating.html
- https://docs.spongepowered.org/stable/en/plugin/commands/service.html
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.