mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
Revert "Item: restrict bounds of count to 0-255"
This reverts commit 10317527e4012fb1dbb1661f2f7fc33b05a7a6d1. this breaks user code which exceeds stack limits in legitimate circumstances. For example, it should be OK to add 6000x diamond to a player's inventory without being forced to manually split the count up for addItem().
This commit is contained in:
parent
53067c26d7
commit
7aa8bd18d3
@ -557,10 +557,6 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCount(int $count) : Item{
|
public function setCount(int $count) : Item{
|
||||||
if($count < 0 or $count > 255){
|
|
||||||
throw new \InvalidArgumentException("Count must be in the range 0-255");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->count = $count;
|
$this->count = $count;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -89,18 +89,4 @@ class ItemTest extends TestCase{
|
|||||||
self::assertEquals($id, $item->getId());
|
self::assertEquals($id, $item->getId());
|
||||||
self::assertEquals($meta, $item->getDamage());
|
self::assertEquals($meta, $item->getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetCountTooBig() : void{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$item = ItemFactory::get(ItemIds::STONE);
|
|
||||||
$item->setCount(256);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetCountTooSmall() : void{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$item = ItemFactory::get(ItemIds::STONE);
|
|
||||||
$item->setCount(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user