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

Solved Server crashed because onCommand

Discussion in 'Plugin Help' started by GeistFan, Nov 13, 2022.

  1. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Hey again, I just finished a new plugin and i wanted to test it but the server just crashed. I get this error:
    Error: Declaration of ForeverCMD\main::eek:nCommand(pocketmine\command\Command $cmd, pocketmine\command\CommandSender $sender, array $args, string $label): bool must be compatible with pocketmine\plugin\PluginBase::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, string $label, array $args): bool
    I just don't know what it means because I think mine and the "Compatible" are the same.
     
  2. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    I solved it, strangely you had to put the uses in the right order...
    Now i have another error that says: pocketmine\plugin\PluginManager::registerEvent(): Argument #1 ($event) must be of type string, ForeverCMD\main given, called in C:\Users\arese\Desktop\PocketMine-MP-stable\plugins\forevercmd\src\forevercmd\main.php on line 24
    Does anyone know what i'm doing wrong? I didn't code since PM3.20
     
  3. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Heres the Code by the way
    Code:
    public function onEnable(): void
        {
            $this->getLogger()->info("ForeverCMD is activated!");
            $this->getServer()->getPluginManager()->registerEvent($this, $this);
            @mkdir($this->getDataFolder());
            $this->saveDefaultConfig();
            $this->getResource("config.yml");
        }
     
  4. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Solved!
     
  5. Arefem

    Arefem Creeper

    Messages:
    3
    public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
    {

    //your cmd

    return true;
    }
     
  6. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Not onCommand is my problem, my problem is onEnable!
     
  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.