CommandService within DynamicCommand

Hi @imagejan

Do you know how I get a CommandService from within a class that extends DynamicCommand?

CommandService cs

Above does not work because DynamicCommand has a private field CommandService already and thus it complains that this is a clash. On the other hand, since this field is private (and not protected) I cannot access it from my child class :frowning:

That issue is very similar to what’s been discussed here:

and was fixed in this commit:

The long-term solution could possibly be to make commandService protected instead of private.

What puzzles me is that before the above-mentioned change to moduleService, I was in fact able to define my own parameter moduleService in my command, with any errors.

@Christian_Tischer did you try:

  1. making the CommandService parameter private to your own command?
  2. if 1) alone doesn’t help, naming it exactly commandService as in the parent class?

In the above statement, I forgot that the original change that broke things for OptionPlugins was the addition of a new private field moduleService (as discussed in the linked topic), so that case is indeed different from the one here. Making the field protected is the only solution I can think of, then.

1 Like

That’s what I thought…