SpongeDocs icon indicating copy to clipboard operation
SpongeDocs copied to clipboard

Add information on how to override / underride vanilla commands

Open ryantheleach opened this issue 9 years ago • 6 comments

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.

ryantheleach avatar May 06 '15 00:05 ryantheleach

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

boformer avatar May 07 '15 11:05 boformer

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

ryantheleach avatar Jan 12 '16 16:01 ryantheleach

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

boformer avatar Jan 13 '16 14:01 boformer

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 avatar Jan 13 '16 18:01 ryantheleach

@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 to CommandManager 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

ST-DDT avatar Aug 07 '18 17:08 ST-DDT

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.

ryantheleach avatar Aug 08 '18 00:08 ryantheleach