How would i send a message to a player on EntityArmorChangeEvent? Or how to do i get the player from entity? If that makes sense.
PHP has weak typing. So you can start using the entity as a player. You do need to make sure that it is a Player though (instanceof) because if you try to call a Player function on an entity the server will crash.
Wait so i tried this and it did not do anything. Im not sure if that is what you were saying. PHP: public function ArmorChange (EntityArmorChangeEvent $ev){ if ($ev->getEntity() instanceof Player){ //what do i do here } } i tried $ev->getEntity()->sendMessage("Test"); but got nothing EDIT nvm figure what i didnt do. If anyone wanted to know what worked: PHP: public function ArmorChange (EntityArmorChangeEvent $ev){ $entity = $ev->getEntity() if ($entity instanceof Player){ $entity->sendMessage("Hello"); } }
How does nonstrict typing relate to this issue? In many type-strict languages, class inheritance allows that anyway.
If you have strict typing then you should only be able to access the methods declared in Entity, not in Player. Yes, Player can override Entity's implementations, but shouldn't be adding new methods.