Hello, so I am trying to make a player to move on another world on a OnInteract founction. Here is the code PHP: elseif($item->getCustomName() == "§bDiamond"){ $player->sendMessage(""); $player->sendMessage($this-> prefix . Color::RED . " §7Du wurdest zu §6SkyWars §7teleportiert"); $player->teleport(new Position(-186, 19, 278, $this->getServer()->getLevelByName(Diamond))); $player->getlevel()->addSound(new EndermanTeleportSound($player)); $player->getInventory()->clearAll(); $player->getInventory()->setSize(9); $player->getInventory()->setItem(7, Item::get(339)->setCustomName("§aInfo")); $player->getInventory()->setItem(0, Item::get(345)->setCustomName("§eGames")); $player->getInventory()->setItem(6, Item::get(388)->setCustomName("§2Your Profile")); $player->getInventory()->setItem(8, Item::get(54)->setCustomName("§aGadgets")); I am getting this error : Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'Lobby':Class 'Lobby/Position' not found on Lobby\Main Error: "Class 'Lobby\Position' not found" (EXCEPTION) in "Lobby/src/Lobby/Main at line 251. This is what I tried : 1.I tried to write other code like this : PHP: $level = $player->getServer()->getLevelByName("Diamond"); $ev->getPlayer()->teleport($ev->getPlayer()->getLevel($level)->getSafeSpawn()); 2. I tried to fix that with a hammer but sadly, it didn't work. Oh and between, $ev is $event ( public function onInteract(PlayerInteractEvent $ev) ) I am not sure to understand this error..If someone can help
The first error occurred because you did not import the Position class. Your second attempt failed, because Player::getLevel() has no arguments, as it simply returns the world that the player is in. Try this code: PHP: $player->teleport($this->getServer()->getLevelByName("Diamond")->getSafeSpawn());
I get this error : [06:32:45] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'LobbySystem v1': Call to a member function getSafeSpawn() on null on Lobby\Main [06:32:45] [Server thread/CRITICAL]: Error: "Call to a member function getSafeSpawn() on null" (EXCEPTION) in "LobbySystem-master/src/Lobby/Main" at line 251
Make sure the argument of Server::getLevelByName() is your world name. Replace Diamond with your world name. It's case sensitive.