Hello, I'm kinda new to plugin development and I have come across a problem within the plugin I am creating. Basically when I run the command /Mine-A ingame it's supposed to teleport the user to the set coordinates within the level "flat" But whenever I run the command it teleports me to the set coordinates within the level I am in Here is the code $x = 243; $y = 29; $z = 241; $level = $this->getServer()->getLevelByName("flat"); $sender->teleport(new Position($x, $y, $z, $level)); Any help would be greatly appreciated.
If the level ware to be unloaded, running position->getLevel() should give you a warning in your console. As shown here: PHP: /** * Returns the target Level, or null if the target is not valid. * If a reference exists to a Level which is closed, the reference will be destroyed and null will be returned. * * @return Level|null */ public function getLevel(){ if($this->level !== null and $this->level->isClosed()){ MainLogger::getLogger()->debug("Position was holding a reference to an unloaded world"); $this->level = null; } return $this->level; } (https://github.com/pmmp/PocketMine-...100bcd0/src/pocketmine/level/Position.php#L59)
So I changed it to $x = 243; $y = 29; $z = 241; $this->getServer()->loadLevel("flat"); $level = $this->getServer()->getLevelByName("flat"); $sender->teleport(new Position($x, $y, $z, $level)); Yet it still doesn't work, it just teleports me to the coordinates within the level I am not to the set coordinates in the level flat. Additionally no error appears in the console so I guess it successfully loads the level "flat"