mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
BaseInventory: validate given array in setContents() (#5391)
This commit is contained in:
parent
29301614e8
commit
1e9d83f014
@ -27,6 +27,7 @@ use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\ObjectSet;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function max;
|
||||
@ -85,6 +86,7 @@ abstract class BaseInventory implements Inventory{
|
||||
* @phpstan-param array<int, Item> $items
|
||||
*/
|
||||
public function setContents(array $items) : void{
|
||||
Utils::validateArrayValueType($items, function(Item $item) : void{});
|
||||
if(count($items) > $this->getSize()){
|
||||
$items = array_slice($items, 0, $this->getSize(), true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user