diff --git a/src/pocketmine/inventory/AnvilInventory.php b/src/pocketmine/inventory/AnvilInventory.php index c13d87251..37490a105 100644 --- a/src/pocketmine/inventory/AnvilInventory.php +++ b/src/pocketmine/inventory/AnvilInventory.php @@ -40,10 +40,6 @@ class AnvilInventory extends ContainerInventory{ return WindowTypes::ANVIL; } - public function getName() : string{ - return "Anvil"; - } - public function getDefaultSize() : int{ return 2; //1 input, 1 material } @@ -56,7 +52,7 @@ class AnvilInventory extends ContainerInventory{ return $this->holder; } - public function onClose(Player $who) : void{ + protected function onClose(Player $who) : void{ parent::onClose($who); foreach($this->getContents() as $item){ diff --git a/src/pocketmine/inventory/ArmorInventory.php b/src/pocketmine/inventory/ArmorInventory.php index 7ecc438af..ac5154129 100644 --- a/src/pocketmine/inventory/ArmorInventory.php +++ b/src/pocketmine/inventory/ArmorInventory.php @@ -50,10 +50,6 @@ class ArmorInventory extends BaseInventory{ return $this->holder; } - public function getName() : string{ - return "Armor"; - } - public function getDefaultSize() : int{ return 4; } diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 17fe9e66c..c0c8c1cf3 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -41,10 +41,6 @@ abstract class BaseInventory implements Inventory{ /** @var int */ protected $maxStackSize = Inventory::MAX_STACK; - /** @var string */ - protected $name; - /** @var string */ - protected $title; /** @var \SplFixedArray|Item[] */ protected $slots = []; /** @var Player[] */ @@ -55,21 +51,13 @@ abstract class BaseInventory implements Inventory{ /** * @param Item[] $items * @param int $size - * @param string $title */ - public function __construct(array $items = [], ?int $size = null, ?string $title = null){ + public function __construct(array $items = [], ?int $size = null){ $this->slots = new \SplFixedArray($size ?? $this->getDefaultSize()); - $this->title = $title ?? $this->getName(); $this->setContents($items, false); } - abstract public function getName() : string; - - public function getTitle() : string{ - return $this->title; - } - /** * Returns the size of the inventory. * @return int @@ -401,21 +389,20 @@ abstract class BaseInventory implements Inventory{ $this->onClose($who); } - public function onOpen(Player $who) : void{ + protected function onOpen(Player $who) : void{ $this->viewers[spl_object_id($who)] = $who; } - public function onClose(Player $who) : void{ + protected function onClose(Player $who) : void{ unset($this->viewers[spl_object_id($who)]); } - public function onSlotChange(int $index, Item $before, bool $send) : void{ + protected function onSlotChange(int $index, Item $before, bool $send) : void{ if($send){ $this->sendSlot($index, $this->getViewers()); } } - /** * @param Player|Player[] $target */ diff --git a/src/pocketmine/inventory/ChestInventory.php b/src/pocketmine/inventory/ChestInventory.php index feb079d5f..cbf63df12 100644 --- a/src/pocketmine/inventory/ChestInventory.php +++ b/src/pocketmine/inventory/ChestInventory.php @@ -46,10 +46,6 @@ class ChestInventory extends ContainerInventory{ return WindowTypes::CONTAINER; } - public function getName() : string{ - return "Chest"; - } - public function getDefaultSize() : int{ return 27; } @@ -70,7 +66,7 @@ class ChestInventory extends ContainerInventory{ return LevelSoundEventPacket::SOUND_CHEST_CLOSED; } - public function onOpen(Player $who) : void{ + protected function onOpen(Player $who) : void{ parent::onOpen($who); if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){ @@ -80,7 +76,7 @@ class ChestInventory extends ContainerInventory{ } } - public function onClose(Player $who) : void{ + protected 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); diff --git a/src/pocketmine/inventory/ContainerInventory.php b/src/pocketmine/inventory/ContainerInventory.php index b807b0b08..3db1072f3 100644 --- a/src/pocketmine/inventory/ContainerInventory.php +++ b/src/pocketmine/inventory/ContainerInventory.php @@ -35,10 +35,10 @@ abstract class ContainerInventory extends BaseInventory{ public function __construct(Vector3 $holder, array $items = [], ?int $size = null, ?string $title = null){ $this->holder = $holder; - parent::__construct($items, $size, $title); + parent::__construct($items, $size); } - public function onOpen(Player $who) : void{ + protected function onOpen(Player $who) : void{ parent::onOpen($who); $pk = new ContainerOpenPacket(); $pk->windowId = $who->getWindowId($this); @@ -61,7 +61,7 @@ abstract class ContainerInventory extends BaseInventory{ $this->sendContents($who); } - public function onClose(Player $who) : void{ + protected function onClose(Player $who) : void{ $pk = new ContainerClosePacket(); $pk->windowId = $who->getWindowId($this); $who->sendDataPacket($pk); diff --git a/src/pocketmine/inventory/CraftingGrid.php b/src/pocketmine/inventory/CraftingGrid.php index 4beb9ed71..1c2ca40e3 100644 --- a/src/pocketmine/inventory/CraftingGrid.php +++ b/src/pocketmine/inventory/CraftingGrid.php @@ -65,10 +65,6 @@ class CraftingGrid extends BaseInventory{ throw new \BadMethodCallException("Cannot change the size of a crafting grid"); } - public function getName() : string{ - return "Crafting"; - } - public function setItem(int $index, Item $item, bool $send = true) : bool{ if(parent::setItem($index, $item, $send)){ $this->seekRecipeBounds(); diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 45df2d92d..06b439551 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -43,10 +43,6 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ BaseInventory::__construct($items); } - public function getName() : string{ - return "Double Chest"; - } - public function getDefaultSize() : int{ return $this->left->getDefaultSize() + $this->right->getDefaultSize(); } @@ -113,7 +109,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ } } - public function onOpen(Player $who) : void{ + protected function onOpen(Player $who) : void{ parent::onOpen($who); if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){ @@ -121,7 +117,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ } } - public function onClose(Player $who) : void{ + protected function onClose(Player $who) : void{ if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){ $this->right->broadcastBlockEventPacket(false); } diff --git a/src/pocketmine/inventory/EnchantInventory.php b/src/pocketmine/inventory/EnchantInventory.php index 059b229b6..80709f5c9 100644 --- a/src/pocketmine/inventory/EnchantInventory.php +++ b/src/pocketmine/inventory/EnchantInventory.php @@ -40,10 +40,6 @@ class EnchantInventory extends ContainerInventory{ return WindowTypes::ENCHANTMENT; } - public function getName() : string{ - return "Enchantment Table"; - } - public function getDefaultSize() : int{ return 2; //1 input, 1 lapis } @@ -56,7 +52,7 @@ class EnchantInventory extends ContainerInventory{ return $this->holder; } - public function onClose(Player $who) : void{ + protected function onClose(Player $who) : void{ parent::onClose($who); foreach($this->getContents() as $item){ diff --git a/src/pocketmine/inventory/EnderChestInventory.php b/src/pocketmine/inventory/EnderChestInventory.php index ce0f1e51e..f3dc11f76 100644 --- a/src/pocketmine/inventory/EnderChestInventory.php +++ b/src/pocketmine/inventory/EnderChestInventory.php @@ -41,10 +41,6 @@ class EnderChestInventory extends ChestInventory{ return WindowTypes::CONTAINER; } - public function getName() : string{ - return "EnderChest"; - } - public function getDefaultSize() : int{ return 27; } diff --git a/src/pocketmine/inventory/FurnaceInventory.php b/src/pocketmine/inventory/FurnaceInventory.php index 00f876b76..1418adb47 100644 --- a/src/pocketmine/inventory/FurnaceInventory.php +++ b/src/pocketmine/inventory/FurnaceInventory.php @@ -39,10 +39,6 @@ class FurnaceInventory extends ContainerInventory{ return WindowTypes::FURNACE; } - public function getName() : string{ - return "Furnace"; - } - public function getDefaultSize() : int{ return 3; //1 input, 1 fuel, 1 output } diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php index cf251d03e..edbdfc46a 100644 --- a/src/pocketmine/inventory/Inventory.php +++ b/src/pocketmine/inventory/Inventory.php @@ -47,16 +47,6 @@ interface Inventory{ */ public function setMaxStackSize(int $size) : void; - /** - * @return string - */ - public function getName() : string; - - /** - * @return string - */ - public function getTitle() : string; - /** * @param int $index * @@ -212,11 +202,6 @@ interface Inventory{ */ public function getViewers() : array; - /** - * @param Player $who - */ - public function onOpen(Player $who) : void; - /** * Tries to open the inventory to a player * @@ -228,18 +213,6 @@ interface Inventory{ public function close(Player $who) : void; - /** - * @param Player $who - */ - public function onClose(Player $who) : void; - - /** - * @param int $index - * @param Item $before - * @param bool $send - */ - public function onSlotChange(int $index, Item $before, bool $send) : void; - /** * Returns whether the specified slot exists in the inventory. * diff --git a/src/pocketmine/inventory/PlayerCursorInventory.php b/src/pocketmine/inventory/PlayerCursorInventory.php index b967139f5..370704f8d 100644 --- a/src/pocketmine/inventory/PlayerCursorInventory.php +++ b/src/pocketmine/inventory/PlayerCursorInventory.php @@ -34,10 +34,6 @@ class PlayerCursorInventory extends BaseInventory{ parent::__construct(); } - public function getName() : string{ - return "Cursor"; - } - public function getDefaultSize() : int{ return 1; } diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index d6db90a99..fd566acd2 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -48,10 +48,6 @@ class PlayerInventory extends BaseInventory{ parent::__construct(); } - public function getName() : string{ - return "Player"; - } - public function getDefaultSize() : int{ return 36; }