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

Solved Too Few Arguement

Discussion in 'Development' started by JarguarLoveMC, Mar 30, 2019.

  1. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    49
    30.03 00:55:16 [Server] Server thread/CRITICAL ArgumentCountError: "Too few arguments to function CE\Enchant\sections\FlashLightHandler::__construct(), 0 passed in phar:///plugins/CE (53).phar/src/CE/Enchant/Main.php on line 296 and exactly 1 expected" (EXCEPTION) in "plugins/CE (53).phar/src/CE/Enchant/sections/FlashLightHandler" at line 32

    FlashLightHandler.php

    PHP:
        public function __construct(Main $plugin) {           //line 32
            
    $this->plugin $plugin;
        }

        public function 
    onRun(int $currentTick) {
     
            foreach (
    $this->plugin->getServer()->getOnlinePlayers() as $player) {
                
    $enchantment $player->getArmorInventory()->getBoots()->getEnchantment(CustomIDs::FLASHLIGHT);
                if (
    $enchantment !== null) {
                    
    $player->addEffect(new EffectInstance(Effect::getEffect(Effect::POISON), $duration 100$amplifier 0$visible true$ambient false));
                }
            }
        }
    }
    Main.php

    PHP:
        public function registerHandlers(): void{
            foreach(
    $this->enchants as $enchant){
                    
    $this->getServer()->getPluginManager()->registerEvents(new $class(), $this);    //line 296
     
    Last edited: Mar 30, 2019
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    public function registerHandlers(): void{
        foreach(
    $this->enchants as $enchant){
            
    $this->getServer()->getPluginManager()->registerEvents(new $class($this), $this);
        }
    }
    I don't know where $class is defined
     
    JarguarLoveMC 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.