diff options
author | Chris Ward <chris@chrisgward.com> | 2013-12-13 19:41:57 +1100 |
---|---|---|
committer | Chris Ward <chris@chrisgward.com> | 2013-12-13 19:41:57 +1100 |
commit | 1bfab68932310c458b66ae3c62a5b7235c28829f (patch) | |
tree | 90a382ab65a1e4b6c8a82147644bdc53e23ce707 | |
parent | 901b835ae0eba9ae3ddb9413851c9a76784b6569 (diff) | |
download | Essentials-1bfab68932310c458b66ae3c62a5b7235c28829f.tar Essentials-1bfab68932310c458b66ae3c62a5b7235c28829f.tar.gz Essentials-1bfab68932310c458b66ae3c62a5b7235c28829f.tar.lz Essentials-1bfab68932310c458b66ae3c62a5b7235c28829f.tar.xz Essentials-1bfab68932310c458b66ae3c62a5b7235c28829f.zip |
Change teleport safety checks to use less expensive methods.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Teleport.java | 16 |
1 files 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); } } |