<?php namespace Linux\Comandos; use pocketmine\Player; use pocketmine\Server; use pocketmine\event\Listener; use pocketmine\event\player\PlayerLoginEvent; use pocketmine\event\player\PlayerQuitEvent; use pocketmine\event\player\PlayerJoinEvent; use Linux\Main; class BHub implements Listener{ public $owner; public function __construct(Main $owner){ $this->owner = $owner; } public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onJoin(PlayerJoinEvent $event){ $this->$player = $event->getPlayer(); $player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation(), 0, 0); $player->sendTip(" "); } }
[Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'LinuxCore v1': Call to undefined method Linux\Comandos\BHub::getServer() on Linux\Comandos\BHub [Server thread/CRITICAL]: Error: "Call to undefined method Linux\Comandos\BHub::getServer()" (EXCEPTION) in "/LinuxCore_v1/src/Linux/Comandos/BHub" at line 34
In order to use $this->geServer() you will need to extend your main class to the PluginBase class. This is the reason it says that getServer is undefined.
That's how OOP works, the getServer() method belongs to the PluginBase class, and you can use it by inheriting from PluginBase.
What you could do is use `$sender->getServer()` because the Player class contains a getServer() method which returns a server instance.
There is a lot wrong with this code, better start all over, with clear intentions. What are you trying to do @Ask Soares?