mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
EntityFactory: remove requirement for $className as return type on creation funcs
since the removal of EntityFactory::create() this isn't needed anymore, since these creation functions are only used for creating entities loaded from disk.
This commit is contained in:
parent
bf401421fa
commit
40d49b88dd
@ -161,12 +161,11 @@ final class EntityFactory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-param class-string<Entity> $baseClass
|
|
||||||
* @phpstan-param \Closure(World, CompoundTag) : Entity $creationFunc
|
* @phpstan-param \Closure(World, CompoundTag) : Entity $creationFunc
|
||||||
*/
|
*/
|
||||||
private static function validateCreationFunc(string $baseClass, \Closure $creationFunc) : void{
|
private static function validateCreationFunc(\Closure $creationFunc) : void{
|
||||||
$sig = new CallbackType(
|
$sig = new CallbackType(
|
||||||
new ReturnType($baseClass),
|
new ReturnType(Entity::class),
|
||||||
new ParameterType("world", World::class),
|
new ParameterType("world", World::class),
|
||||||
new ParameterType("nbt", CompoundTag::class)
|
new ParameterType("nbt", CompoundTag::class)
|
||||||
);
|
);
|
||||||
@ -193,7 +192,7 @@ final class EntityFactory{
|
|||||||
throw new \InvalidArgumentException("At least one save name must be provided");
|
throw new \InvalidArgumentException("At least one save name must be provided");
|
||||||
}
|
}
|
||||||
Utils::testValidInstance($className, Entity::class);
|
Utils::testValidInstance($className, Entity::class);
|
||||||
self::validateCreationFunc($className, $creationFunc);
|
self::validateCreationFunc($creationFunc);
|
||||||
|
|
||||||
foreach($saveNames as $name){
|
foreach($saveNames as $name){
|
||||||
$this->creationFuncs[$name] = $creationFunc;
|
$this->creationFuncs[$name] = $creationFunc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user