mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Added BaseInventory->removeAllViewers()
This commit is contained in:
parent
1641183674
commit
68809d992b
@ -541,10 +541,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
public function close(){
|
||||
if(!$this->closed){
|
||||
if($this->inventory !== null){
|
||||
foreach($this->inventory->getViewers() as $viewer){
|
||||
$viewer->removeWindow($this->inventory);
|
||||
}
|
||||
|
||||
$this->inventory->removeAllViewers(true);
|
||||
$this->inventory = null;
|
||||
}
|
||||
parent::close();
|
||||
|
@ -349,6 +349,17 @@ abstract class BaseInventory implements Inventory{
|
||||
return $this->viewers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the inventory window from all players currently viewing it.
|
||||
* @param bool $force Force removal of permanent windows such as the player's own inventory. Used internally.
|
||||
*/
|
||||
public function removeAllViewers(bool $force = false) : void{
|
||||
foreach($this->viewers as $hash => $viewer){
|
||||
$viewer->removeWindow($this, $force);
|
||||
unset($this->viewers[$hash]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getHolder(){
|
||||
return $this->holder;
|
||||
}
|
||||
|
@ -59,15 +59,10 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
|
||||
public function close(){
|
||||
if($this->closed === false){
|
||||
foreach($this->getInventory()->getViewers() as $player){
|
||||
$player->removeWindow($this->getInventory());
|
||||
}
|
||||
|
||||
foreach($this->getInventory()->getViewers() as $player){
|
||||
$player->removeWindow($this->getRealInventory());
|
||||
}
|
||||
$this->inventory->removeAllViewers(true);
|
||||
|
||||
if($this->doubleInventory !== null){
|
||||
$this->doubleInventory->removeAllViewers(true);
|
||||
$this->doubleInventory->invalidate();
|
||||
$this->doubleInventory = null;
|
||||
}
|
||||
|
@ -97,10 +97,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
|
||||
public function close(){
|
||||
if($this->closed === false){
|
||||
foreach($this->getInventory()->getViewers() as $player){
|
||||
$player->removeWindow($this->getInventory());
|
||||
}
|
||||
|
||||
$this->inventory->removeAllViewers(true);
|
||||
$this->inventory = null;
|
||||
|
||||
parent::close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user