Implement getting the jail nearest to sender of the jail command if no

jail parameter is defined.
This commit is contained in:
graywolf336
2013-12-24 17:51:41 -06:00
parent 64301db196
commit dc2e74a63e
7 changed files with 91 additions and 13 deletions

View File

@ -245,4 +245,17 @@ public class Jail {
return r;
}
/**
* Returns the squared distance between teleport location of this jail
* and specified location in blocks. If locations are not in same world,
* distance cannot be calculated and it will return Integer.MAX_VALUE.
*
* @param loc The location to check
* @return Distance between the location provided and the teleport in location.
*/
public double getDistance(Location loc) {
if (loc.getWorld().getName().equalsIgnoreCase(getTeleportIn().getWorld().getName())) return (double) Integer.MAX_VALUE;
else return loc.distance(getTeleportIn());
}
}