Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved error on PlayerPreLoginEvent

Comments in 'Plugin Development' started by xBeastMode, Dec 17, 2015.

Thread Status:
Not open for further replies.
  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    WTF! This has never happened to me, why is this hapenning? I set array of players on wait for spamming. They will be unbanned when schedule delayed task runs. The problem is on PlayerPreLoginEvent. The server crashes with a crashdump when I check if player is set in the array.
    PHP:
    //my code
    public function onPrelogin(PlayerPreLoginEvent $e)
        {
            if(isset(
    $this->onWait[$e->getPlayer()->getName()]))
            {
                
    $time $this->onWait[$e->getPlayer()->getName()];
                
    $e->getPlayer()->kick($this->par("%1%You are still banned. Reason: spamming the chat."color::RED));
            }
        }
    Code:
    PocketMine-MP Crash Dump Wed Dec 16 20:48:29 AKST 2015
    
    Error: Call to a member function hasPermission() on null
    File: /src/pocketmine/Player__32bit
    Line: 449
    Type: E_ERROR
    
    Code:
    [440]         return $this->perm->isPermissionSet($name);
    [441]     }
    [442]
    [443]     /**
    [444]      * @param permission\Permission|string $name
    [445]      *
    [446]      * @return bool
    [447]      */
    [448]     public function hasPermission($name){
    [449]         return $this->perm->hasPermission($name);
    [450]     }
    [451]
    [452]     /**
    [453]      * @param Plugin $plugin
    [454]      * @param string $name
    [455]      * @param bool   $value
    [456]      *
    [457]      * @return permission\PermissionAttachment
    [458]      */
    [459]     public function addAttachment(Plugin $plugin, $name = \null, $value = \null){
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Instead of kicking the player, why not simply cancel the event?
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    It's PocketMine's issue use another build. or as @Gamecrafter said
    PHP:
    public function onPreLogin(PlayerPreLoginEvent $e){
    $e->setKickMessage("You're still banned");
    $e->setCancelled(true); // For safety i always put true
    }
    Mod edit: This is a plugin issue, not PocketMine. More info on https://github.com/PocketMine/PocketMine-MP/pull/3694
    Last edited by a moderator: Dec 17, 2015
    Skullex and PEMapModder like this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement