VanillaEffects: return null instead of throwing on invalid effect ID

we don't expect plugin devs to be using this any more, and it doesn't make sense to throw on data deserialize. This throw was unchecked and a potential server crash might have occurred in Living on data load.
This commit is contained in:
Dylan K. Taylor 2019-12-12 13:54:05 +00:00
parent a9c09e4517
commit 89458660cf

View File

@ -107,14 +107,11 @@ final class VanillaEffects{
/**
* @param int $id
*
* @return Effect
* @return Effect|null
*/
public static function byMcpeId(int $id) : Effect{
public static function byMcpeId(int $id) : ?Effect{
self::checkInit();
if(!isset(self::$mcpeIdMap[$id])){
throw new \InvalidArgumentException("No such effect with MCPE ID $id");
}
return self::$mcpeIdMap[$id];
return self::$mcpeIdMap[$id] ?? null;
}
/**