Hey! I wanna make the following plugin: The nearest player, they are in the near of the spawn, get a message like "You are in the near of the spawn!". Does anyone know how can I make this plugin? Thanks!
PHP: $distance = PHP_INT_MAX;$player = null;$lvl = $this->getServer()->getLevelByName("world");foreach($lvl->getPlayers() as $pl){ if($pl->distanceSquared($lvl->getSafeSpawn()) < $distance){ $distance = $pl->distanceSquared($lvl->getSafeSpawn()); $player = $pl; }}if($player != null){ $player->sendMessage("Hi");}