Using distance function. PHP: public function onDamage(EntityDamageEvent $e){$spawn = $this->getServer()->getDefaultLevel()->getSafeSpawn();$p =$e->getEntity();$distance = $p->distance($spawn);if($p instanceof Player){if($distance > 10){$e->setCancelled();}}}