private Pair<PlayerData, PlayerData> getNearFarPlayers(ArrayList<PlayerData> players){
        PlayerData closestPlayer = new PlayerData(); // make a new place to record the closest player
        PlayerData furthestPlayer = new PlayerData(); // make a new place to record the furthest player
        closestPlayer.setDistanceTo(104); // set the distance of the closest one to the maximum distance
        furthestPlayer.setDistanceTo(0); // set the distance of the furthest one to the minimum distance
        for(PlayerData x : players){ //for each player in the vidible players arrayList,
            if(x.getDistanceTo() < closestPlayer.getDistanceTo()){
                closestPlayer = x; // the closest player in the list is saved to the closestPlayer variable
            }
            if(x.getDistanceTo() > furthestPlayer.getDistanceTo()){
                furthestPlayer = x; // the furthest player in the list is saved to the furthestPlayer variable
            }
        }
        //save the details to a pair
        Pair<PlayerData, PlayerData> p = new Pair();
        p.setLeft(closestPlayer);
        p.setRight(furthestPlayer);
        return p;
    }