mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Inventory: drop useless proxy functions
This commit is contained in:
parent
787d305c2a
commit
f671f2ebfa
@ -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]);
|
||||
}
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -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)]);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user