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

Solved Plugin Crashes Server (bad title ik)

Discussion in 'Development' started by ethaniccc, May 26, 2020.

  1. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    So basically in a plugin I'm making called Mockingbird, I use the close() function to kick the player with a message. The player gets kicked, but the server crashes with the error:

    Code:
    [15:15:33] [Server thread/INFO]: coEthaniccc was removed from the game for the suspicion of using hacks in-game. They will be able to rejoin in 300 seconds.
    [15:15:33] [Server thread/CRITICAL]: Error: "Call to a member function getBlockAt() on null" (EXCEPTION) in "src/pocketmine/entity/Entity" at line 1474
    I tried the same thing with kick(), but it crashed as well.
    I (now) know this isn't a Pocketmine issue because /ban works just fine.
    You can check all the code (if you have the time) here: https://github.com/ethaniccc/Mockingbird
    I have no idea why this is happening, so if you could help me that would be nice.
    (The only enabled detections at that time were Speed, I disabled the rest)

    Thanks in advance!
     
  2. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Hello friend xD
     
    ethaniccc likes this.
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Can you screenshot the code or paste it into here?
    Also that is not a code ^^"
     
  4. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Also is it $player->close()?
     
  5. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    I used kick() and close(), but still got the same error
    Code:
    [15:15:33] [Server thread/CRITICAL]: Error: "Call to a member function getBlockAt() on null" (EXCEPTION) in "src/pocketmine/entity/Entity" at line 1474
    PHP:
    public static function blockPlayer(Player $player){
            
    $seconds self::$blockedAddresses[$player->getAddress()];
            
    $player->kick(TextFormat::BOLD TextFormat::RED "Mockingbird AntiCheat\n" TextFormat::RESET TextFormat::AQUA "You were removed from the server for using cheats in-game.\nYou will be able to join back in $seconds seconds.\nIf this was an error, contact staff."false);
        }
    It kicks the player with the message, but right after, the server crashes
     
    Last edited: May 26, 2020
  6. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
  7. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    PHP:
    public function isUnderwater() : bool{
            
    $block $this->level->getBlockAt((int) floor($this->x), (int) floor($y = ($this->$this->getEyeHeight())), (int) floor($this->z));

            if(
    $block instanceof Water){
                
    $f = ($block->1) - ($block->getFluidHeightPercent() - 0.1111111);
                return 
    $y $f;
            }

            return 
    false;
        }
     
  8. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Where is $player->kick() or $player->close() located?
     
  9. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Code:
    [15:15:33] [Server thread/CRITICAL]: Error: "Call to a member function getBlockAt() on null" (EXCEPTION) in "src/pocketmine/entity/Entity" at line 1474
    PHP:
    $block $this->level->getBlockAt((int) floor($this->x), (int) floor($y = ($this->$this->getEyeHeight())), (int) floor($this->z));
    I think $this->level is null, is this bug happens when you teleport to another map?
     
  10. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    Could be, but after actually getting some sleep I have a thought (I'm on my phone RN). Thinking back to my code, I realize that it closes the player before any check is complete, which is probably why it's giving that error, because it's still trying to call a function from that player even though it no longer exists on the server.
     
  11. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
  12. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You should not kick the player during the event because most of the events rely on the player to continue, schedule a task to kick
     
  13. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    Scheduling a task worked perfectly, thank you!
     
  14. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    nice
     
  15. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Uh, scheduling a task may cause lag. Sync task will be a better choice but not really
     
  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.