mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Use covariant types for InventoryHolder and Container implementors
This commit is contained in:
parent
38cf9fc6e6
commit
f2dc9187f0
@ -41,7 +41,7 @@ class DoubleChestInventory extends BaseInventory implements BlockInventory, Inve
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getInventory(){
|
||||
public function getInventory() : self{
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -56,17 +56,11 @@ class Barrel extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BarrelInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : BarrelInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BarrelInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : BarrelInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
|
@ -112,17 +112,11 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BrewingStandInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : BrewingStandInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BrewingStandInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : BrewingStandInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
|
@ -114,20 +114,14 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$this->containerTraitBlockDestroyedHook();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChestInventory|DoubleChestInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : ChestInventory|DoubleChestInventory{
|
||||
if($this->isPaired() && $this->doubleInventory === null){
|
||||
$this->checkPairing();
|
||||
}
|
||||
return $this->doubleInventory instanceof DoubleChestInventory ? $this->doubleInventory : $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChestInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : ChestInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,7 @@ interface Container extends InventoryHolder{
|
||||
public const TAG_ITEMS = "Items";
|
||||
public const TAG_LOCK = "Lock";
|
||||
|
||||
/**
|
||||
* @return Inventory
|
||||
*/
|
||||
public function getRealInventory();
|
||||
public function getRealInventory() : Inventory;
|
||||
|
||||
/**
|
||||
* Returns whether this container can be opened by an item with the given custom name.
|
||||
|
@ -38,10 +38,7 @@ trait ContainerTrait{
|
||||
/** @var string|null */
|
||||
private $lock = null;
|
||||
|
||||
/**
|
||||
* @return Inventory
|
||||
*/
|
||||
abstract public function getRealInventory();
|
||||
abstract public function getRealInventory() : Inventory;
|
||||
|
||||
protected function loadItems(CompoundTag $tag) : void{
|
||||
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||
|
@ -104,17 +104,11 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FurnaceInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : FurnaceInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FurnaceInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : FurnaceInventory{
|
||||
return $this->getInventory();
|
||||
}
|
||||
|
||||
|
@ -69,17 +69,11 @@ class Hopper extends Spawnable implements Container, Nameable{
|
||||
return "Hopper";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HopperInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : HopperInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HopperInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : HopperInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
}
|
||||
|
@ -93,17 +93,11 @@ class ShulkerBox extends Spawnable implements Container, Nameable{
|
||||
$this->facing = $facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShulkerBoxInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : ShulkerBoxInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShulkerBoxInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
public function getRealInventory() : ShulkerBoxInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
|
@ -189,10 +189,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
return min(100, 7 * $this->xpManager->getXpLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayerInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : PlayerInventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,5 @@ namespace pocketmine\inventory;
|
||||
|
||||
interface InventoryHolder{
|
||||
|
||||
/**
|
||||
* Get the object related inventory
|
||||
*
|
||||
* @return Inventory
|
||||
*/
|
||||
public function getInventory();
|
||||
public function getInventory() : Inventory;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user