Error [13:13:47] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to Msg\commands\Home::__construct() must be of the type string, object given, called in /home/Faction(2)/plugins/SkyMsg/src/Msg/SkyMsg.php on line 66" (EXCEPTION) in "SkyMsg/src/Msg/commands/Home" at line 13] Here is my code <?php namespace Msg\commands; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\Server; use pocketmine\Player; use pocketmine\level\Level; use pocketmine\level\Position; use pocketmine\utils\TextFormat as TX; use pocketmine\utils\Config; use Msg\SkyMsg; class Home extends Command { public function __construct(string $name){ parent::__construct( $name, "Teleport to your home or See the list of yours homes", "/home <nameofthehome-list>", ["maison"] ); } public function nombreHome(Player $player){ $main = Main::getInstance(); if(!file_exists($main->getDataFolder()."/homes/".$player->getName().".yml")) return false; $homes = new Config($main->getDataFolder()."/homes/".$player->getName().".yml",Config::YAML); return count($homes->getAll()); } public function execute(CommandSender $sender, $command, array $args){ if(!$sender instanceof Player) return false; $main = Main::getInstance(); $sr = Server::getInstance(); if (count($args) != 1) return $sender->sendMessage(TX::RED."[EasyServer] Error: ".TX::RESET." Bad usage! Good usage: /home name-of-the-home OR /home list"); if(!file_exists($main->getDataFolder()."/homes/".$sender->getName().".yml")){ $sender->sendMessage(TX::RED."[EasyServer] Error:".TX::RESET." It seems that you don't have homes create one with /sethome name"); return false; } $homes = new Config($main->getDataFolder()."/homes/".$sender->getName().".yml",Config::YAML); if($args[0] == "list" OR $args[0] == "ls" ){ $lst =$homes->getAll(); $sender->sendMessage(TX::RED."[EasyServer]: You have ".count($lst)." homes:"); foreach($lst as $hm){ $tt = explode("_",$hm); $sender->sendMessage("- ".$tt[0]); } }else{ if(!$homes->exists($args[0])){ return $sender->sendMessage(TX::RED."[EasyServer] Error:".TX::RESET."You don't have a home with that name!"); } $all = explode("_",$homes->get($args[0])); $x = (float) $all[1]; $y = (float) $all[2]; $z = (float) $all[3]; $level = $sr->getLevelByName($all[4]); if(!$level instanceof Level){ $sender->sendMessage(TX::RED."[EasyServer] Error:".TX::RED." ...I tried ".mt_rand(0,100)." times and the level where your home is don't reply! re-Try later"); return false; } $sender->teleport(new Position($x, $y, $z, $level)); $sender->sendMessage(TX::GREEN."[EasyServer] Welcome back to your home!"); return true; } } }
You should look at this plugin to see how to make a command in other file [NOT ADVERTISE] https://github.com/TwistedAsylumMC/PotatoeCore
Look at SkyMsg/src/Msg/SkyMsg.php on line 66, there should be something like new Home(...) It requires a string as the first argument but an object is passed to it
Pretty easy to understand. Your Home class's constructor requires first parameter to be a string but you fed it a plugin instance. Why?