ItemFactory: do not reuse the same itemstack instance for air()

this is mutable, so it's possible for plugins to mess with it and break everything that references it.
This commit is contained in:
Dylan K. Taylor 2020-10-04 18:36:46 +01:00
parent c42a6d7552
commit 505d4e402f

View File

@ -52,9 +52,6 @@ class ItemFactory{
/** @var Item[] */
private $list = [];
/** @var Item|null */
private static $air = null;
public function __construct(){
$this->registerArmorItems();
$this->registerSpawnEggs();
@ -448,7 +445,7 @@ class ItemFactory{
}
public static function air() : Item{
return self::$air ?? (self::$air = self::getInstance()->get(ItemIds::AIR, 0, 0));
return self::getInstance()->get(ItemIds::AIR, 0, 0);
}
/**