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

Error help

Discussion in 'General discussion' started by Hoangviphb999, Feb 17, 2022.

  1. Hoangviphb999

    Hoangviphb999 Silverfish

    Messages:
    21
    GitHub:
    Hoangviphb999
    So i updating a PocketMine plugin called Duels, i got this error when i type create command and it said:
    TypeError: "vixikhd\duels\arena\Arena::__construct(): Argument #1 ($plugin) must be of type vixikhd\duels\Duels, null given, called in C:\Users\Dotuananh\Desktop\pmmp lib\plugins\Duels\src\vixikhd\duels\commands\DuelsCommand.php on line 99" (EXCEPTION) in "plugins/Duels/src/vixikhd/duels/arena/Arena" at line 116
    And here is my code on both DuelsCommand.php and Arena.php:
    case "create":
    if (!$sender->hasPermission("duels.cmd.create")) {
    $sender->sendMessage("§cYou have not permissions to use this command!");
    break;
    }
    if (!isset($args[1])) {
    $sender->sendMessage("§cUsage: §7/sw create <arenaName>");
    break;
    }
    if (isset($this->plugin->arenas[$args[1]])) {
    $sender->sendMessage("§c> Arena $args[1] already exists!");
    break;
    }
    $this->plugin->arenas[$args[1]] = new Arena($this->plugin, []);
    This thing is line 99
    $sender->sendMessage("§a> Arena $args[1] created!");
    break;
    Now is from Arena.php:
    public function __construct(Duels $plugin, array $arenaFileData)That code is on line 66
    {
    $this->plugin = $plugin;
    $this->data = $arenaFileData;
    $this->setup = !$this->enable(false);

    $this->plugin->getScheduler()->scheduleRepeatingTask($this->scheduler = new ArenaScheduler($this), 20);

    if ($this->setup) {
    if (empty($this->data)) {
    $this->createBasicData();
    $this->plugin->getLogger()->error("Could not load arena {$this->data["level"]}");
    } else {
    $this->plugin->getLogger()->error("Could not load arena {$this->data["level"]}, complete setup.");
    }
    } else {
    $this->loadArena();
    }
    }
     
  2. Axon

    Axon Zombie

    Messages:
    276
    Please surround your code with code blocks.
    Eg:
    [ PHP] code here.. [ /PHP]
     
  3. Axon

    Axon Zombie

    Messages:
    276
    Check what's $this->plugin variable.
     
  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.