Fixed a bunch of things PHPStan finds unpalatable

close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
This commit is contained in:
Dylan K. Taylor
2019-01-04 00:23:09 +00:00
parent 5e0c3333cf
commit d71a543d10
11 changed files with 62 additions and 39 deletions

View File

@ -196,16 +196,21 @@ class PlayerInventory extends BaseInventory{
}
public function sendCreativeContents(){
//TODO: this mess shouldn't be in here
$holder = $this->getHolder();
if(!($holder instanceof Player)){
throw new \LogicException("Cannot send creative inventory contents to non-player inventory holder");
}
$pk = new InventoryContentPacket();
$pk->windowId = ContainerIds::CREATIVE;
if(!$this->getHolder()->isSpectator()){ //fill it for all gamemodes except spectator
if(!$holder->isSpectator()){ //fill it for all gamemodes except spectator
foreach(Item::getCreativeItems() as $i => $item){
$pk->items[$i] = clone $item;
}
}
$this->getHolder()->dataPacket($pk);
$holder->dataPacket($pk);
}
/**