my error: Code: Unhandled exception executing command 'minas' in minas: Argument 4 passed to pocketmine\level\Position::__construct() must be an instance of pocketmine\level\Level, string given, called in C:\Users\DanielYTK\Documents\PocketMine-MP\plugins\Teleportes\src\DanielYTK\Main.php on line 55 my code: PHP: <?phpnamespace DanielYTK;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use pocketmine\level\Position;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\utils\Config;class Main extends PluginBase implements Listener{ public function onEnable(){ $plano = array( 'y' => 0, 'x' => 0, 'z' => 0, 'world' => "", ); Server::getInstance()->getLogger()->info("§aNo§cWarps§f - §aHabilitado"); Server::getInstance()->getPluginManager()->registerEvents($this, $this); @mkdir($this->getDataFolder()); $this->minas = new Config($this->getDataFolder()."minas.yml",Config::YAML,$plano); $this->minas->save(); $this->minapvp = new Config($this->getDataFolder()."minapvp.yml",Config::YAML,$plano); $this->minapvp->save(); $this->plots = new Config($this->getDataFolder()."plots.yml",Config::YAML,$plano); $this->plots->save(); $this->loja = new Config($this->getDataFolder()."loja.yml",Config::YAML,$plano); $this->loja->save(); $this->lojavip = new Config($this->getDataFolder()."lojavip.yml",Config::YAML,$plano); $this->lojavip->save(); $this->lobby = new Config($this->getDataFolder()."lobby.yml",Config::YAML,$plano); $this->lobby->save(); $this->arena = new Config($this->getDataFolder()."arena.yml",Config::YAML,$plano); $this->arena->save(); //cmds : minas,minapvp,plots,loja,lojavip,lobby,arena } public function onDisable() { Server::getInstance()->getLogger()->info("§aNo§cWarps§f - §aDesabilitado"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch (strtolower($command->getName())){ case "minas": if(!isset($args[0])){ if($sender->isOp()){ $sender->sendMessage("§cVocê pode setar o local com: /minas setar"); if(!Server::getInstance()->isLevelLoaded($this->minas->get('world'))){ Server::getInstance()->loadLevel($this->minas->get('world')); $sender->sendMessage("§aO mundo foi carregado!"); } } $sender->teleport(new Position($this->minas->get('x'), $this->minas->get('y'), $this->minas->get('z'), $this->minas->get('world'))); //line 55 } if(strtolower($args[0]) == "setar"){ if($sender->isOp()){ $x = $sender->getX(); $y = $sender->getY(); $z = $sender->getZ(); $world = $sender->getLevel()->getFolderName(); $this->minas->set('x', $x); $this->minas->set('y', $y); $this->minas->set('z', $z); $this->minas->set('world', $world); $sender->sendMessage("§aMinas setada!"); $this->minas->save(); } else { $sender->sendMessage("§cVocê não é OPERADOR"); } } break;
You're trying to make a position of a saved string as level. As the crash dumb says, Position::__construct() requires a Level, not a string. Change it to PHP: $this->getServer()->getLevelByName($this->minas->get('world')) And it should do the job.