From 1bfab68932310c458b66ae3c62a5b7235c28829f Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Fri, 13 Dec 2013 19:41:57 +1100 Subject: Change teleport safety checks to use less expensive methods. --- Essentials/src/com/earth2me/essentials/Teleport.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 82b8f8cf6..c46ceedf5 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -97,14 +97,22 @@ 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 { - throw new Exception(_("unsafeTeleportDestination")); + teleportee.getBase().teleport(location); } } -- cgit v1.2.3