Hi everybody. How can I get Slapper's nametag, just to making for my CustomQuests plugin. If I interact with a specified Slapper with their nametag, it'll appear a UI or doing other events,...
use statments: PHP: use jojoe77777\FormAPI;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\plugin\PluginBase;use slapper\entities\SlapperHuman; code, Example, Explain: PHP: /*** @param EntityDamageByEntityEvent $event*/public function onEntityClick(EntityDamageByEntityEvent $event) { $slapper = $event->getEntity(); $slapperName = $slapper->getNameTag(); $player = $event->getDamager(); if ($slapper instanceof Slapper) { //if you are clicking on slapper if ($slapperName === "Test") { //if slapper name is Test $this->whatEveryouWant($player); //open a form menu to player (who clicking slapper) } }}
PHP: public function onEntityDamage(EntityDamageEvent $event): void { $entity = $event->getEntity(); $cause = $entity->getLastDamageCause(); if ($entity instanceof SmaccerEntity || $entity instanceof SmaccerHuman) { $event->setCancelled(true); if (!$event instanceof EntityDamageByEntityEvent) { return; } if($cause instanceof EntityDamageByEntityEvent){ $damager = $cause->getDamager(); if($damager instanceof Player){ if ($entity instanceof SmaccerEntity || $entity instanceof SmaccerHuman) { if ($slapperName === "custom name from UI") { QuestManager::onQuestEvent($damager, "interact"); } } } } } } I used Smaccer, forked from Slapper with all of Slapper's addon in 1 plugin because it's very easy to use