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 | a343d6e9f664675088b03ae0cd037d1bd640a427 (patch) | |
tree | 4707a10b4304bfcc016519cb66d2d2ef6c20c15f | |
parent | bb681f2d7b500f8418014f1e22d7c1a6734eab02 (diff) | |
download | Essentials-a343d6e9f664675088b03ae0cd037d1bd640a427.tar Essentials-a343d6e9f664675088b03ae0cd037d1bd640a427.tar.gz Essentials-a343d6e9f664675088b03ae0cd037d1bd640a427.tar.lz Essentials-a343d6e9f664675088b03ae0cd037d1bd640a427.tar.xz Essentials-a343d6e9f664675088b03ae0cd037d1bd640a427.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); } } |