Hello, I'm making a plugin where certain ranked players with permission can be able to hit staff in the world "Hub". If they have permission, they can be able to hit staff. It will only be knockback; there will be no damage implemented. Is there any way to do that? Thank you!
Code: public function staffHit(EntityDamageEvent $event) { $entity = $event->getEntity(); if($entity->getLevel()->getName() == "Your lobby world name?") { // Update this to your lobby world name if($entity instanceof Player) { if($event instanceof EntityDamageByEntityEvent) { $player = $event->getDamager(); if($player instanceof Player) { if($entity->hasPermission("xzero.staff")) { // Update this to the permission you'd want. $event->setBaseDamage(0); $player->sendMessage("Woah! You hit " . $entity->getName() . ", be a good boy!"); // A little extra } } } } } }
How would I make it so that the player has to have permission to hit the staff member, and the staff takes knockback?
Okay, done. What about the knockback? [EDIT] I found out from a past thing I made, thanks for the help!