From 47a959dace95eafe79212a444e3f865475c6ee8e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 Dec 2019 09:29:22 +0000 Subject: [PATCH] block: fix some possible crashes when plugins overwrite tile classes in bad ways phpstan was complaining on level 2, and it's not wrong to ... --- src/pocketmine/block/BurningFurnace.php | 3 +++ src/pocketmine/block/Chest.php | 3 +++ src/pocketmine/block/ItemFrame.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 01bbd6779..c189f5b65 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -80,6 +80,9 @@ class BurningFurnace extends Solid{ $furnace = $this->getLevel()->getTile($this); if(!($furnace instanceof TileFurnace)){ $furnace = Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this)); + if(!($furnace instanceof TileFurnace)){ + return true; + } } if(!$furnace->canOpenWith($item->getCustomName())){ diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index b11809ef2..a9cadbb1b 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -109,6 +109,9 @@ class Chest extends Transparent{ $chest = $t; }else{ $chest = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this)); + if(!($chest instanceof TileChest)){ + return true; + } } if( diff --git a/src/pocketmine/block/ItemFrame.php b/src/pocketmine/block/ItemFrame.php index 6038e0a55..6644c682b 100644 --- a/src/pocketmine/block/ItemFrame.php +++ b/src/pocketmine/block/ItemFrame.php @@ -47,6 +47,9 @@ class ItemFrame extends Flowable{ $tile = $this->level->getTile($this); if(!($tile instanceof TileItemFrame)){ $tile = Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this)); + if(!($tile instanceof TileItemFrame)){ + return true; + } } if($tile->hasItem()){