1.14.4 Use multiple class command executor for same command ?

Discussion in 'Spigot Plugin Development' started by iCrossing, Feb 3, 2020.

  1. Hi, I want to know if it is possible to use multiple class that implements command executors which execute the same command ?

    Like that:

    Code (Java):
    main.getCommand("commandName").setExecutor(new Admin());

    main.getCommand("commandName").setExecutor(new SettingsCmd());

    main.getCommand("commandName").setExecutor(new LocationsCmd());

    Thanks :)
  2. i have no idea what you wanna do with this?, either 3 commands or subcommands like /commandname subcommand do_whatever_you_want
  3. SteelPhoenix


    multiple commands can have the same executor, but not the other way around. You can of course create one CommandExecutor that forwards it to (multiple) other executors.

    But, what do you want to achieve? Sounds like a x/y problem.
  4. Ok, just wanted to create 3 different classes to make my code look like clean but maybe I will do a single class
  5. Ok thank you for your answer. I will just organise my code in a sigle class I think
  6. You can still outsource logic into other classes. Suppose you had something like a heal-command, you could create a class HealManager that is responsible for healing the player (obviously a very simple example, but should show the direction)
    • Like Like x 1
  7. Rather you could simply seperate the arguments in methods
    • Like Like x 1