mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
PlayerInventory: fix type violation when calling equipItem() for non-Player holder
This commit is contained in:
parent
919534d978
commit
9a4b72add5
@ -66,19 +66,23 @@ class PlayerInventory extends BaseInventory{
|
|||||||
* @return bool if the equipment change was successful, false if not.
|
* @return bool if the equipment change was successful, false if not.
|
||||||
*/
|
*/
|
||||||
public function equipItem(int $hotbarSlot) : bool{
|
public function equipItem(int $hotbarSlot) : bool{
|
||||||
|
$holder = $this->getHolder();
|
||||||
if(!$this->isHotbarSlot($hotbarSlot)){
|
if(!$this->isHotbarSlot($hotbarSlot)){
|
||||||
$this->sendContents($this->getHolder());
|
if($holder instanceof Player){
|
||||||
|
$this->sendContents($holder);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ev = new PlayerItemHeldEvent($this->getHolder(), $this->getItem($hotbarSlot), $hotbarSlot);
|
if($holder instanceof Player){
|
||||||
|
$ev = new PlayerItemHeldEvent($holder, $this->getItem($hotbarSlot), $hotbarSlot);
|
||||||
$ev->call();
|
$ev->call();
|
||||||
|
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
$this->sendHeldItem($this->getHolder());
|
$this->sendHeldItem($holder);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->setHeldItemIndex($hotbarSlot, false);
|
$this->setHeldItemIndex($hotbarSlot, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user