summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2011-12-27 06:05:24 -0500
committerTahg <tahgtahv@gmail.com>2012-01-09 01:20:54 -0500
commit355c7ba24115709642db9c40f092d2ab12639af5 (patch)
tree0d117e8e4305907453dca7140da9046b5d1c9383 /src
parent7f37ce3dc1736b9113de566a55d9b41ba6d9a120 (diff)
downloadbukkit-355c7ba24115709642db9c40f092d2ab12639af5.tar
bukkit-355c7ba24115709642db9c40f092d2ab12639af5.tar.gz
bukkit-355c7ba24115709642db9c40f092d2ab12639af5.tar.lz
bukkit-355c7ba24115709642db9c40f092d2ab12639af5.tar.xz
bukkit-355c7ba24115709642db9c40f092d2ab12639af5.zip
improved some debug in Location
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/Location.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index f4b8c989..4afabd88 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -360,11 +360,7 @@ public class Location implements Cloneable {
* @throws IllegalArgumentException for differing worlds
*/
public double distance(Location o) {
- if (o == null || o.getWorld() != getWorld()) {
- throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
- }
-
- return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2));
+ return Math.sqrt(distanceSquared(o));
}
/**
@@ -376,8 +372,10 @@ public class Location implements Cloneable {
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
- if (o == null || o.getWorld() != getWorld()) {
- throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
+ if (o == null) {
+ throw new IllegalArgumentException("Cannot measure distance to a null world");
+ } else if (o == null || o.getWorld() != getWorld()) {
+ throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2);