1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Error Plugin!

Discussion in 'Plugin Help' started by Ask Soares, Oct 1, 2019.

?

Error in console . Find

  1. No

  2. N

Multiple votes are allowed.
Results are only viewable after voting.
  1. Ask Soares

    Ask Soares Creeper

    Messages:
    3
    <?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(" ");
    }
    }
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    If you have an error in the console, why don't you share it with us?
     
  3. Ask Soares

    Ask Soares Creeper

    Messages:
    3
    [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
     
  4. Mohagames205

    Mohagames205 Spider Jockey

    Messages:
    26
    GitHub:
    mohagames205
    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.
     
    EdwardHamHam likes this.
  5. Ask Soares

    Ask Soares Creeper

    Messages:
    3
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    That's how OOP works, the getServer() method belongs to the PluginBase class, and you can use it by inheriting from PluginBase.
     
    EdwardHamHam likes this.
  7. Mohagames205

    Mohagames205 Spider Jockey

    Messages:
    26
    GitHub:
    mohagames205
    What you could do is use `$sender->getServer()` because the Player class contains a getServer() method which returns a server instance.
     
  8. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You can use $this->owner->getServer()
     
  9. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    There is a lot wrong with this code, better start all over, with clear intentions. What are you trying to do @Ask Soares?
     
    EdwardHamHam likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.