mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Improved safe_var_dump(), Inventory::addItem() Inventory::removeItem() using argument unpacking
This commit is contained in:
@ -225,9 +225,8 @@ abstract class BaseInventory implements Inventory{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addItem(){
|
||||
public function addItem(...$slots){
|
||||
/** @var Item[] $slots */
|
||||
$slots = func_get_args();
|
||||
foreach($slots as $i => $slot){
|
||||
$slots[$i] = clone $slot;
|
||||
}
|
||||
@ -264,9 +263,8 @@ abstract class BaseInventory implements Inventory{
|
||||
return $slots;
|
||||
}
|
||||
|
||||
public function removeItem(){
|
||||
public function removeItem(...$slots){
|
||||
/** @var Item[] $slots */
|
||||
$slots = func_get_args();
|
||||
for($i = 0; $i < $this->getSize(); ++$i){
|
||||
$item = $this->getItem($i);
|
||||
if($item->getID() === Item::AIR){
|
||||
|
@ -73,7 +73,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function addItem();
|
||||
public function addItem(...$slots);
|
||||
|
||||
/**
|
||||
* Checks if a given Item can be added to the inventory
|
||||
@ -92,7 +92,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function removeItem();
|
||||
public function removeItem(...$slots);
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
|
Reference in New Issue
Block a user