1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-07 23:27:08 +02:00

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); cancel(false);
teleportee.setLastLocation(); teleportee.setLastLocation();
Location safeDestination = LocationUtil.getSafeDestination(teleportee, target.getLocation()); final Location location = target.getLocation();
if (ess.getSettings().isTeleportSafetyEnabled() || (target.getLocation().getBlockX() == safeDestination.getBlockX() && target.getLocation().getBlockY() == safeDestination.getBlockY() && target.getLocation().getBlockZ() == safeDestination.getBlockZ()))
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 else
{ {
throw new Exception(_("unsafeTeleportDestination")); 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. //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. //This method is nolonger used internally and will be removed.