From acb794e7281e6127640510da90e7d3f680a91a7d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Oct 2018 16:35:51 +0100 Subject: [PATCH] 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? --- .../event/entity/EntityDespawnEvent.php | 40 ---------------- .../event/entity/EntitySpawnEvent.php | 48 ------------------- 2 files changed, 88 deletions(-) diff --git a/src/pocketmine/event/entity/EntityDespawnEvent.php b/src/pocketmine/event/entity/EntityDespawnEvent.php index 3831041e6..1978f6079 100644 --- a/src/pocketmine/event/entity/EntityDespawnEvent.php +++ b/src/pocketmine/event/entity/EntityDespawnEvent.php @@ -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; - } } diff --git a/src/pocketmine/event/entity/EntitySpawnEvent.php b/src/pocketmine/event/entity/EntitySpawnEvent.php index 8a8f1484f..e20b98dbc 100644 --- a/src/pocketmine/event/entity/EntitySpawnEvent.php +++ b/src/pocketmine/event/entity/EntitySpawnEvent.php @@ -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; - } }