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

Error in my Plugin "Too few arguments to function pocketmine\Server::getPlayer()"

Discussion in 'Development' started by SpongeBoZZ, May 16, 2020.

  1. SpongeBoZZ

    SpongeBoZZ Creeper

    Messages:
    2
    Hello can somebody help me ? I have this error in 2 Plugins since 2 Days, I asked in Discord but nobody can helpsme, hope you can guys thx.
    Here the complete Error:
    [Server thread/CRITICAL]: ArgumentCountError: "Too few arguments to function pocketmine\Server::getPlayer(), 0 passed in /home/minecraft/plugins/rewardPlugin/src/SpongeBoZZ/rewardPlugin/Main.php on line 25 and exactly 1 expected" (EXCEPTION) in "src/pocketmine/Server" at line 794

    Here ist the Code:

    <?php

    declare(strict_types=1);

    namespace SpongeBoZZ\rewardPlugin;

    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\plugin\PluginBase;

    class Main extends PluginBase{

    public $listOfCoolDown = [];

    public function onEnable()
    {
    $this->getLogger()->warning("Plugin aktiviert");
    }

    public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
    {
    switch ($command->getName()) {
    case "reward":
    if (!isset($this->listOfCoolDown[$sender->getName()])) {
    $this->listOfCoolDown[$sender->getName()] = time() + 60;

    $sender->sendMessage("Du wirst deine Belohnung erhalten !");
    } else {
    if (time() < $this->listOfCoolDown[$sender->getName()]) {
    $remaining = $this->listOfCoolDown[$sender->getName()] - time();
    $sender->sendPopup("Countdown: " . $remaining);
    }
    else{
    unset($this->listOfCoolDown[$sender->getName()]);
    }
    }
    break;
    }
    return true;
    }

    public function onDisable()
    {
    $this->getLogger()->warning("Plugin deaktiviert !");
    }

    }
     
  2. MrJackx5

    MrJackx5 Spider

    Messages:
    9
    is it a .phar if it is it could be another plugin messing it up
     
  3. Notzide

    Notzide Creeper

    Messages:
    1
    GitHub:
    notzide
    There is nothing in your code about SERVER try to rethink the way you made this.
     
  4. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    The error says what its supposw to say you are not passing in arguments that its expecting to the function.
     
  5. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Too few arguments to function pocketmine\Server::getPlayer(), 0 passed in /home/minecraft/plugins/rewardPlugin/src/SpongeBoZZ/rewardPlugin/Main.php on line 25 and exactly 1 expected
    Did you read the error before making this post?
     
    Provsnoobgaming likes this.
  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.