static public Vector findPath(Location from, Location to) {
double dX = from.getX() - to.getX();
double dY = from.getY() - to.getY();
double dZ = from.getZ() - to.getZ();
double yaw = Math.atan2(dZ, dX);
double pitch = Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI;
double X = Math.sin(pitch) * Math.cos(yaw);
double Y = Math.sin(pitch) * Math.sin(yaw);
double Z = Math.cos(pitch);
Vector vector = new Vector(X, Z, Y);
return vector;
}
static public String GetNearPlayer(Player player1) // получение списка игроков которые находяться рядом
{
final long radius = 100;
final Location loc = player1.getLocation();
final World world = loc.getWorld();
final StringBuilder output = new StringBuilder();
final long radiusSquared = radius * radius;
for (Player player2: Bukkit.getServer().getOnlinePlayers())
{
final Location playerLoc = player2.getLocation();
if (playerLoc.getWorld() != world || player2.getDisplayName() == player1.getDisplayName())
{
continue;
}
final long delta = (long)playerLoc.distanceSquared(loc);
if (delta < radiusSquared)
{
if (output.length() > 0)
{
output.append("§f,§e ");
}
output.append("§e"+player2.getDisplayName()).append(" §7(").append((long)Math.sqrt(delta)).append("м) §fто что выдаёт findPath §a"+findPath(loc, playerLoc));
}
}
return output.length() > 1 ? output.toString() : "none";
}