I have been working on a plugin and it doesn't work (obviously). I have tried to fix it several times but to no avail. Here is the code: PHP: <?phpnamespace Hittmana\VipGate;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\event\Listener;use pocketmine\event\player\PlayerMoveEvent;class MainClass extends PluginBase implements Listener{ public function onEnable() { $this->getLogger()->info("VipGate enabled v1.0.0"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onDisable() { $this->getLogger()->info("VipGate disabled v1.0.0"); } public function onMove(PlayerMoveEvent $event) { $player = $event->getPlayer(); $block = $player->getLevel()->getBlock($player->floor()->subtract(0, 1)); if ($block == "activator_rail" or $block == "126") { $event->getPlayer()->teleport($this->getServer()->getLevelByName()->getSafeSpawn()); } } } And here is the error: Code: Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'VipGate v1.0.0': Method pocketmine\block\ActivatorRail::__toString() must return a string value on Hittmana\VipGate\MainClass 2016-04-17 [08:40:30] [Server thread/NOTICE]: RuntimeException: "Method pocketmine\block\ActivatorRail::__toString() must return a string value" (E_RECOVERABLE_ERROR) in "/VipGate_v1.0.0.phar/src/HittmanA/VipGate/MainClass" at line 26 Please help!
The method getBlock on your PlayerMoveEvent handler returns an object, not an integer or a string. You should use getId method if you want check block's ID. https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/block/Block.php
I changed it to PHP: $block = $player->getLevel()->getId($player->floor()->subtract(0, 1)); And now it does nothing, it doesn't even send anything to the console.
First, you need to get the block first: PHP: $block = $player->getLevel()->getBlock(new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ())); Then, check if id = 126: PHP: $block = $player->getLevel()->getBlock(new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ()));if($block->getId() == 126){} Last, tp player to level: PHP: $block = $player->getLevel()->getBlock(new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ()));if($block->getId() == 126){ $player->teleport($this->getServer()->getLevelByName("Name")->getSafeSpawn());} You have to use /pocketmine/math/Vector3