mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Change teleport safety checks to use less expensive methods.
This commit is contained in:
parent
901b835ae0
commit
1bfab68932
@ -97,16 +97,24 @@ 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
|
||||
{
|
||||
teleportee.getBase().teleport(location);
|
||||
}
|
||||
}
|
||||
|
||||
//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.
|
||||
|
Loading…
Reference in New Issue
Block a user