Loop players in X block range

I’m making chat plugin, and I have 2 types of it - global and local. When player will send message, I wanna send it to players in X block range (only X and Z cords) from sender (Is like X to be Java int).

When someone is in send range, I’d like to start sendMessage(Player p) : void function.

Try something like this

double x;
double z;
int range;
Vector2d vector2 = new Vector2d(x, z);
Set<Player> playersInRange = Sponge.getServer().getPlayers().stream().filter(p -> {
    Vector3d vector3 = p.getLocation().getPosition();
    return vector2.distance(vector3.getX(), vector3.getZ()) =< range;