mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Merge branch 'stable' into next-minor
This commit is contained in:
@ -76,11 +76,13 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
* @phpstan-param array<int, Item> $items
|
||||
*/
|
||||
abstract protected function internalSetContents(array $items) : void;
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
* @phpstan-param array<int, Item> $items
|
||||
*/
|
||||
public function setContents(array $items) : void{
|
||||
if(count($items) > $this->getSize()){
|
||||
@ -132,6 +134,7 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
return $slots;
|
||||
}
|
||||
|
||||
public function first(Item $item, bool $exact = false) : int{
|
||||
$count = $exact ? $item->getCount() : max(1, $item->getCount());
|
||||
$checkDamage = $exact || !$item->hasAnyDamageValue();
|
||||
|
@ -47,12 +47,20 @@ interface Inventory{
|
||||
public function setItem(int $index, Item $item) : void;
|
||||
|
||||
/**
|
||||
* Returns an array of all the itemstacks in the inventory, indexed by their slot number.
|
||||
* Empty slots are not included unless includeEmpty is true.
|
||||
*
|
||||
* @return Item[]
|
||||
* @phpstan-return array<int, Item>
|
||||
*/
|
||||
public function getContents(bool $includeEmpty = false) : array;
|
||||
|
||||
/**
|
||||
* Sets the contents of the inventory. Non-numeric offsets or offsets larger than the size of the inventory are
|
||||
* ignored.
|
||||
*
|
||||
* @param Item[] $items
|
||||
* @phpstan-param array<int, Item> $items
|
||||
*/
|
||||
public function setContents(array $items) : void;
|
||||
|
||||
@ -85,8 +93,10 @@ interface Inventory{
|
||||
/**
|
||||
* Will return all the Items that has the same id and metadata (if not null).
|
||||
* Won't check amount
|
||||
* The returned array is indexed by slot number.
|
||||
*
|
||||
* @return Item[]
|
||||
* @phpstan-return array<int, Item>
|
||||
*/
|
||||
public function all(Item $item) : array;
|
||||
|
||||
|
@ -58,6 +58,7 @@ class SimpleInventory extends BaseInventory{
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
* @phpstan-return array<int, Item>
|
||||
*/
|
||||
public function getContents(bool $includeEmpty = false) : array{
|
||||
$contents = [];
|
||||
|
Reference in New Issue
Block a user