I'm getting error with my plugin error: Code: 03:13:29 [CRITICAL] Unhandled exception executing command 'lobby' in lobby: Argument 1 passed to Core\Tasks\LobbyTask::__construct() must be an instance of Core\Main, instance of Core\Commands\Lobby given, called in /root/l/plugins/PrisonCore - Copy/src/Core/Commands/Lobby.php on line 24 03:13:29 [CRITICAL] TypeError: "Argument 1 passed to Core\Tasks\LobbyTask::__construct() must be an instance of Core\Main, instance of Core\Commands\Lobby given, called in /root/l/plugins/PrisonCore - Copy/src/Core/Commands/Lobby.php on line 24" (EXCEPTION) in "/plugins/PrisonCore - Copy/src/Core/Tasks/LobbyTask" at line 15 lobbytask: PHP: <?phpnamespace Core\Tasks;use pocketmine\scheduler\PluginTask;use pocketmine\Player;use Core\Main;use pocketmine\level\Level;use pocketmine\math\Vector3;use Core\Commands\Lobby;class LobbyTask extends PluginTask{ public function __construct(Main $main, Player $player){ parent::__construct($main, $player); $this->main = $main; $this->seconds = 3; $this->player = $player; } lobby.php PHP: <?phpnamespace Core\Commands;use Core\Main;use pocketmine\command\{CommandSender, Command};use Core\Tasks\LobbyTask;use pocketmine\Player;use pocketmine\scheduler\PluginTask;class Lobby extends Command{ public function __construct(Main $main) { parent::__construct("lobby", $main); $this->main = $main; } public function execute(CommandSender $sender, $commandLabel, array $args){ $player = $sender; $task = new LobbyTask($this, $player); $this->main->getServer()->getScheduler()->scheduleRepeatingTask($task, 1*20); return true; }} }
Opps my bad I missed it... //lobby task: public function __construct(Lobby $main, Player $player){ //Your class called Lobby not Main parent::__construct($main, $player); $this->main = $main; $this->seconds = 3; $this->player = $player;[/PHP]
uhhh..my bad up there... PHP: //Lobby taskpublic function __construct(Lobby $main , Player $player) { //Your class is called Lobby not Mainparent::__construct($main , $player);$this->main = $main;$this->seconds = 3;$this->player = $player;}
PHP: <?phpnamespace Core\Commands;use Core\Main;use pocketmine\command\{CommandSender, Command};use Core\Tasks\LobbyTask;use pocketmine\Player;use pocketmine\scheduler\PluginTask;class Lobby extends Command{ public function __construct(Main $main) { parent::__construct("lobby", $main); $this->main = $main; } public function execute(CommandSender $sender, $commandLabel, array $args){ $player = $sender; $task = new LobbyTask($this->main, $player); // not $this but $this->main $this->main->getServer()->getScheduler()->scheduleRepeatingTask($task, 1*20); return true; }} }