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 | 44385ce0242efc16a5b0f12baaacfb6b8e7aa28d (patch) | |
tree | 5fd58fd5466a7eefaa1d6d31b7379b54b7f866d0 /Essentials/src/com/earth2me/essentials/Teleport.java | |
parent | 4b2e4c61f99be39cde65f254e6691dba405afa17 (diff) | |
download | Essentials-44385ce0242efc16a5b0f12baaacfb6b8e7aa28d.tar Essentials-44385ce0242efc16a5b0f12baaacfb6b8e7aa28d.tar.gz Essentials-44385ce0242efc16a5b0f12baaacfb6b8e7aa28d.tar.lz Essentials-44385ce0242efc16a5b0f12baaacfb6b8e7aa28d.tar.xz Essentials-44385ce0242efc16a5b0f12baaacfb6b8e7aa28d.zip |
Change teleport safety checks to use less expensive methods.
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/Teleport.java')
-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); } } |