Hey. I'd like that players spawn in my Lobby, everytime they join onto the server. My code which you can see below, worked perfectly with Tesseract. Since I use PocketMine-MP, it doesn't work anymore. No error outputs, no crashdumps, it just won't work. The class is defined by using "use pocketmine\event\player\PlayerJoinEvent;". If you are reporting a regression or unexpected behaviour, please include the below information: Expected result: Players should spawn at the servers spawn point on join. Actual result: Nothing happens. Players spawn on there last point, before quit. PocketMine-MP: PocketMine-MP 1.6.2dev 「Unleashed」 PHP: 7.0 Server OS: Linux (Ubuntu 14.04) Game version: PE/Win10
Could you please show more of your code. From what we can see, everything would work fine. We don't know however, if you for example forgot to register events, or something similar. Did you forget to implement Listener maybe? Does the plugin even get enabled at all?
These are some parts of the code. The plugin actually is enabled and also the commands like /hub and so on work fine. Only the teleport on join doesn't work :/
The first thing you should do is to read the PocketMine-MP source and find where the event is called from. https://github.com/pmmp/PocketMine-...cd3797a15bf50b/src/pocketmine/Player.php#L898 If you read a little bit more you'll see https://github.com/pmmp/PocketMine-...cd3797a15bf50b/src/pocketmine/Player.php#L918 See the problem?
According to @Intyre's hints, the following happens when a player joins: 1. PlayerJoinEvent is called 2. PlayerRespawnEvent is called. 3. The server teleports the player to the spawn location set in PlayerRespawnEvent. Therefore, you should use PlayerRespawnEvent instead of PlayerJoinEvent to teleport the player.
So the Code would be: PHP: public function onRespawn(PlayerRespawnEvent $respawn){ $player = $respawn->getPlayer(); $player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation()); } ? Is this right? Because I want that the player is getting teleported, when he joins the server. Not when he dies or something else. And it also doesn't work.
No. Set the respawn location in the PlayerRespawnEvent. https://github.com/pmmp/PocketMine-...e/event/player/PlayerRespawnEvent.php#L55-L57
No, you don't need to define this function yourself, you need to call it. Like this: PHP: public function onRespawn(PlayerRespawnEvent $respawn){ $player = $respawn->getPlayer(); $respawn->setRespawnPosition($this->getServer()->getDefaultLevel()->getSpawnLocation());}
Now I've tried many things. But none of them is working :/ I don't think that this is a problem with my plugins or something like that. I think this issue is related to PMMP. thebigsmilexd apparently also had this issue.