mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
Fix crash when new players join due to attempting to send negative inventory slot
This commit is contained in:
parent
57379b93ce
commit
2f306c3a38
@ -103,6 +103,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getItem($index){
|
public function getItem($index){
|
||||||
|
assert($index >= 0, "Inventory slot should not be negative");
|
||||||
return isset($this->slots[$index]) ? clone $this->slots[$index] : Item::get(Item::AIR, 0, 0);
|
return isset($this->slots[$index]) ? clone $this->slots[$index] : Item::get(Item::AIR, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,16 +214,13 @@ class PlayerInventory extends BaseInventory{
|
|||||||
|
|
||||||
if(!is_array($target)){
|
if(!is_array($target)){
|
||||||
$target->dataPacket($pk);
|
$target->dataPacket($pk);
|
||||||
if($target === $this->getHolder()){
|
if($this->getHeldItemSlot() !== -1 and $target === $this->getHolder()){
|
||||||
$this->sendSlot($this->getHeldItemSlot(), $target);
|
$this->sendSlot($this->getHeldItemSlot(), $target);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->getHolder()->getLevel()->getServer()->broadcastPacket($target, $pk);
|
$this->getHolder()->getLevel()->getServer()->broadcastPacket($target, $pk);
|
||||||
foreach($target as $player){
|
if($this->getHeldItemSlot() !== -1 and in_array($this->getHolder(), $target)){
|
||||||
if($player === $this->getHolder()){
|
$this->sendSlot($this->getHeldItemSlot(), $this->getHolder());
|
||||||
$this->sendSlot($this->getHeldItemSlot(), $player);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user