mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Remove garbage from Entity(De)SpawnEvent
These methods: a) add concrete dependencies b) are pointless (event->getEntity() instanceof Creature, anyone? an IDE can better understand this as well...) c) encourage bad code (they don't enforce type contracts the same way an instanceof check does - oh, and why not let's add an is*() for every new mob that gets added ever?
This commit is contained in:
parent
97c836f199
commit
acb794e728
@ -23,12 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\entity;
|
||||
|
||||
use pocketmine\entity\Creature;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Human;
|
||||
use pocketmine\entity\object\ItemEntity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\entity\Vehicle;
|
||||
|
||||
/**
|
||||
* Called when a entity is despawned
|
||||
@ -41,39 +36,4 @@ class EntityDespawnEvent extends EntityEvent{
|
||||
public function __construct(Entity $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCreature() : bool{
|
||||
return $this->entity instanceof Creature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHuman() : bool{
|
||||
return $this->entity instanceof Human;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isProjectile() : bool{
|
||||
return $this->entity instanceof Projectile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isVehicle() : bool{
|
||||
return $this->entity instanceof Vehicle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isItem() : bool{
|
||||
return $this->entity instanceof ItemEntity;
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\entity;
|
||||
|
||||
use pocketmine\entity\Creature;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Human;
|
||||
use pocketmine\entity\object\ItemEntity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\entity\Vehicle;
|
||||
use pocketmine\level\Position;
|
||||
|
||||
/**
|
||||
* Called when a entity is spawned
|
||||
@ -42,46 +36,4 @@ class EntitySpawnEvent extends EntityEvent{
|
||||
public function __construct(Entity $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Position
|
||||
*/
|
||||
public function getPosition() : Position{
|
||||
return $this->entity->getPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCreature() : bool{
|
||||
return $this->entity instanceof Creature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHuman() : bool{
|
||||
return $this->entity instanceof Human;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isProjectile() : bool{
|
||||
return $this->entity instanceof Projectile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isVehicle() : bool{
|
||||
return $this->entity instanceof Vehicle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isItem() : bool{
|
||||
return $this->entity instanceof ItemEntity;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user