mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Merge branch 'master' into mcpe-1.2
This commit is contained in:
@ -256,7 +256,7 @@ class ItemFactory{
|
||||
*/
|
||||
public static function registerItem(Item $item, bool $override = false){
|
||||
$id = $item->getId();
|
||||
if(!$override and self::$list[$id] !== null){
|
||||
if(!$override and self::isRegistered($id)){
|
||||
throw new \RuntimeException("Trying to overwrite an already registered item");
|
||||
}
|
||||
|
||||
@ -350,4 +350,17 @@ class ItemFactory{
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified item ID is already registered in the item factory.
|
||||
*
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRegistered(int $id) : bool{
|
||||
if($id < 256){
|
||||
return BlockFactory::isRegistered($id);
|
||||
}
|
||||
return self::$list[$id] !== null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user