Inventory: drop useless proxy functions

This commit is contained in:
Dylan K. Taylor 2019-06-14 19:37:45 +01:00
parent 787d305c2a
commit f671f2ebfa
8 changed files with 17 additions and 25 deletions

View File

@ -2821,7 +2821,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
if($ev->isCancelled()){
return -1;
}
$inventory->open($this);
$inventory->onOpen($this);
if($isPermanent){
$this->permanentWindows[spl_object_id($inventory)] = true;
}
@ -2844,7 +2844,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$networkId = $this->windows[$objectId] ?? null;
if($networkId !== null){
$inventory->close($this);
$inventory->onClose($this);
unset($this->windows[$objectId], $this->windowIndex[$networkId], $this->permanentWindows[$objectId]);
}
}

View File

@ -23,9 +23,9 @@ declare(strict_types=1);
namespace pocketmine\inventory;
use pocketmine\world\Position;
use pocketmine\network\mcpe\protocol\types\WindowTypes;
use pocketmine\Player;
use pocketmine\world\Position;
class AnvilInventory extends ContainerInventory{
@ -48,7 +48,7 @@ class AnvilInventory extends ContainerInventory{
return $this->holder;
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
parent::onClose($who);
foreach($this->getContents() as $item){

View File

@ -353,19 +353,11 @@ abstract class BaseInventory implements Inventory{
$this->maxStackSize = $size;
}
public function open(Player $who) : void{
$this->onOpen($who);
}
public function close(Player $who) : void{
$this->onClose($who);
}
protected function onOpen(Player $who) : void{
public function onOpen(Player $who) : void{
$this->viewers[spl_object_id($who)] = $who;
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
unset($this->viewers[spl_object_id($who)]);
}

View File

@ -64,7 +64,7 @@ class ChestInventory extends ContainerInventory{
return new ChestCloseSound();
}
protected function onOpen(Player $who) : void{
public function onOpen(Player $who) : void{
parent::onOpen($who);
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
@ -74,7 +74,7 @@ class ChestInventory extends ContainerInventory{
}
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
//TODO: this crap really shouldn't be managed by the inventory
$this->broadcastBlockEventPacket(false);

View File

@ -38,7 +38,7 @@ abstract class ContainerInventory extends BaseInventory{
parent::__construct($size, $items);
}
protected function onOpen(Player $who) : void{
public function onOpen(Player $who) : void{
parent::onOpen($who);
$windowId = $who->getWindowId($this);
@ -52,7 +52,7 @@ abstract class ContainerInventory extends BaseInventory{
$who->getNetworkSession()->syncInventoryContents($this);
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
$who->sendDataPacket(ContainerClosePacket::create($who->getWindowId($this)));
parent::onClose($who);
}

View File

@ -74,7 +74,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
return $result;
}
protected function onOpen(Player $who) : void{
public function onOpen(Player $who) : void{
parent::onOpen($who);
if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){
@ -82,7 +82,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
}
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){
$this->right->broadcastBlockEventPacket(false);
}

View File

@ -23,9 +23,9 @@ declare(strict_types=1);
namespace pocketmine\inventory;
use pocketmine\world\Position;
use pocketmine\network\mcpe\protocol\types\WindowTypes;
use pocketmine\Player;
use pocketmine\world\Position;
class EnchantInventory extends ContainerInventory{
@ -48,7 +48,7 @@ class EnchantInventory extends ContainerInventory{
return $this->holder;
}
protected function onClose(Player $who) : void{
public function onClose(Player $who) : void{
parent::onClose($who);
foreach($this->getContents() as $item){

View File

@ -195,13 +195,13 @@ interface Inventory{
public function getViewers() : array;
/**
* Tries to open the inventory to a player
* Called when a player opens this inventory.
*
* @param Player $who
*/
public function open(Player $who) : void;
public function onOpen(Player $who) : void;
public function close(Player $who) : void;
public function onClose(Player $who) : void;
/**
* Returns whether the specified slot exists in the inventory.