package me.otisdiver.otisarena.utils;

import org.bukkit.Location;
import org.bukkit.entity.Player;

public class LocationUtils {

    /** Calculates the pythagorean distance between two points.
     * 
     * @param al the first location value
     * @param bl the second location value
     * @return the distance between the two locations
     */
    public static double calculateDistance(Location al, Location bl) {
        double ax = al.getX();
        double ay = al.getY();
        double az = al.getZ();
        double bx = bl.getX();
        double by = bl.getY();
        double bz = bl.getZ();
        
        double dx = ax - bx;
        double dy = ay - by;
        double dz = az - bz;
        
        return Math.sqrt(dx * dx + dy * dy + dz * dz);
    }
    
    /** Checks whether two players are within (inclusive) a distance of each other.
     * 
     * @param a the first player
     * @param b the second player
     * @param distance the maximum distance at which true should be returned
     * @return whether Players 'a' and 'b' are within 'distance' of each other
     */
    public static boolean withinDistance(Player a, Player b, double distance) {
        return calculateDistance(a.getLocation(), b.getLocation()) <= distance;
    }
    
}

@@ -210,18 +210,20 @@
  @param 
-a
 l
+ocA
  the fir
@@ -254,18 +254,20 @@
  @param 
-b
 l
+ocB
  the sec
@@ -399,18 +399,20 @@
 ocation 
-a
 l
+ocA
 , Locati
@@ -414,18 +414,20 @@
 ocation 
-b
 l
+ocB
 ) %7B%0A    
@@ -441,51 +441,36 @@
 ble 
-a
+d
 x = 
-a
 l
+ocA
 .getX()
-;%0A        double ay = al
+ - locB
 .get
-Y
+X
 ();%0A
@@ -488,51 +488,36 @@
 ble 
-az
+dy
  = 
-a
 l
+ocA
 .get
-Z();%0A        double bx = bl
+Y() - locB
 .get
-X
+Y
 ();%0A
@@ -535,149 +535,38 @@
 ble 
-by
+dz
  = 
-b
 l
+ocA
 .get
-Y();%0A        double bz = bl.getZ();%0A        %0A        double dx = ax - bx;%0A        double dy = ay - by;%0A        double dz = az - bz
+Z() - locB.getZ()
 ;%0A  

refactor 800aa3f9d248b2eef33c2648b287e75e0622ab82