Change teleport safety checks to use less expensive methods.

This commit is contained in:
Chris Ward 2013-12-13 19:41:57 +11:00
parent 901b835ae0
commit 1bfab68932

View File

@ -97,16 +97,24 @@ public class Teleport implements net.ess3.api.ITeleport
{
cancel(false);
teleportee.setLastLocation();
Location safeDestination = LocationUtil.getSafeDestination(teleportee, target.getLocation());
if (ess.getSettings().isTeleportSafetyEnabled() || (target.getLocation().getBlockX() == safeDestination.getBlockX() && target.getLocation().getBlockY() == safeDestination.getBlockY() && target.getLocation().getBlockZ() == safeDestination.getBlockZ()))
final Location location = target.getLocation();
if (LocationUtil.isBlockUnsafe(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ()))
{
teleportee.getBase().teleport(safeDestination, cause);
if (ess.getSettings().isTeleportSafetyEnabled())
{
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, location));
}
else
{
throw new Exception(_("unsafeTeleportDestination"));
}
}
else
{
teleportee.getBase().teleport(location);
}
}
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
//This method is nolonger used internally and will be removed.