getName() === "Unknown"){ continue; } self::add($item); } } /** * Removes all previously added items from the creative menu. * Note: Players who are already online when this is called will not see this change. */ public static function clear() : void{ self::$creative = []; } /** * @return Item[] */ public static function getAll() : array{ return self::$creative; } public static function getItem(int $index) : ?Item{ return self::$creative[$index] ?? null; } public static function getItemIndex(Item $item) : int{ foreach(self::$creative as $i => $d){ if($item->equals($d, !($item instanceof Durable))){ return $i; } } return -1; } /** * Adds an item to the creative menu. * Note: Players who are already online when this is called will not see this change. */ public static function add(Item $item) : void{ self::$creative[] = clone $item; } /** * Removes an item from the creative menu. * Note: Players who are already online when this is called will not see this change. */ public static function remove(Item $item) : void{ $index = self::getItemIndex($item); if($index !== -1){ unset(self::$creative[$index]); } } public static function contains(Item $item) : bool{ return self::getItemIndex($item) !== -1; } }