1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

external Command

Discussion in 'Development' started by b3st_Thunder78, Jul 18, 2019.

  1. b3st_Thunder78

    b3st_Thunder78 Spider Jockey

    Messages:
    38
    Hello,
    how to register a command that is not written in the main.php file
    So Command has its own class.
    How do you register that because in the Main or in the plugin.yml
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    In the onEnable function of your main class (the one extending PluginBase):
    PHP:
    $this->getServer()->getCommandMap()->register("your plugin's name here", new ClassNameOfYourCommand($this));
    In the constructor of your command class (that extends PluginCommand):
    PHP:
    public function __construct(Plugin $owner) {
         
    parent::__construct("command name here"$owner);
         
    $this->setDescription("Description here");
         
    $this->setUsage("/command usage");
         
    $this->setPermission("permission here");
    }
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.