Enchantment: don't throw exceptions on out of range IDs

this function is used for data deserialization, and data may have bad enchantment IDs in it.
This commit is contained in:
Dylan K. Taylor 2019-12-14 10:04:51 +00:00
parent f7d66613df
commit 2cb6990698

View File

@ -155,6 +155,9 @@ class Enchantment{
* @return Enchantment|null
*/
public static function getEnchantment(int $id) : ?Enchantment{
if($id < 0 or $id >= self::$enchantments->getSize()){
return null;
}
return self::$enchantments[$id] ?? null;
}