Sergittos / BedWars

🛏️ BedWars for PocketMine-MP
GNU Lesser General Public License v3.0
25 stars 6 forks source link

fix return null and crash #17

Closed UnknownNull closed 7 months ago

UnknownNull commented 7 months ago

There are many of these...🥱

Sergittos commented 7 months ago

This doesn't make sense, as Game->getStage() never returns null.

UnknownNull commented 7 months ago

This doesn't make sense, as Game->getStage() never returns null.

It returns null for me in many parts of the code and I am fixing them

But I don't know why Null returns

UnknownNull commented 7 months ago

This is true of course:

    protected function getLines(Session $session): array {
        $game = $session->getGame();
        if($game !== null && $game->getStage() !== null){
            $stage = $session->getGame()->getStage();
            if(!$stage instanceof PlayingStage) {
                return [];
            }

        $event = $stage->getNextEvent();

        return [
            14 => "{GRAY}" . date("m/d/y"),
            13 => " ",
            12 => "{WHITE}" . $event->getName() . " in: {GREEN}" . gmdate("i:s", $event->getTimeRemaining()) . "   ",
            11 => "  ",
        ] + $this->getTeams($session);
        }else{
            return [];
        }
    }
Sergittos commented 7 months ago

Fixed in 1.0.8