summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2014-07-12 16:33:50 +0100
committerKHobbits <rob@khobbits.co.uk>2014-07-12 16:33:50 +0100
commit4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3 (patch)
tree490d5e5a30e6a77e373524c53f291fa0b35030a3
parenta2c692af39a258d8a8130672cef32fcd6f76713b (diff)
downloadEssentials-4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3.tar
Essentials-4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3.tar.gz
Essentials-4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3.tar.lz
Essentials-4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3.tar.xz
Essentials-4e6c98ac57064dbcc6cda4e0b8dcefb601a18bd3.zip
Allow people with god & fly to teleport to unsafe locations even when teleport safety is disabled.
-rw-r--r--Essentials/src/com/earth2me/essentials/Teleport.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/utils/LocationUtil.java22
2 files changed, 20 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index 9fc153d92..4858ad423 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -102,7 +102,7 @@ public class Teleport implements net.ess3.api.ITeleport
teleportee.setLastLocation();
final Location loc = target.getLocation();
- if (LocationUtil.isBlockUnsafe(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
+ if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
{
if (ess.getSettings().isTeleportSafetyEnabled())
{
diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
index aaaa8fc06..7a98a577f 100644
--- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
+++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
@@ -222,6 +222,22 @@ public class LocationUtil
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
}
+ public static boolean isBlockUnsafeForUser(final IUser user, final World world, final int x, final int y, final int z)
+ {
+ if (user.getBase().isOnline() && world.equals(user.getBase().getWorld())
+ && (user.getBase().getGameMode() == GameMode.CREATIVE || user.isGodModeEnabled())
+ && user.getBase().getAllowFlight())
+ {
+ return false;
+ }
+
+ if (isBlockDamaging(world, x, y, z))
+ {
+ return true;
+ }
+ return isBlockAboveAir(world, x, y, z);
+ }
+
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
{
if (isBlockDamaging(world, x, y, z))
@@ -265,9 +281,9 @@ public class LocationUtil
public static Location getSafeDestination(final IUser user, final Location loc) throws Exception
{
- if (loc.getWorld().equals(user.getBase().getWorld())
- && ((user.getBase().getGameMode() == GameMode.CREATIVE
- || user.isGodModeEnabled()) && user.getBase().getAllowFlight()))
+ if (user.getBase().isOnline() && loc.getWorld().equals(user.getBase().getWorld())
+ && (user.getBase().getGameMode() == GameMode.CREATIVE || user.isGodModeEnabled())
+ && user.getBase().getAllowFlight())
{
if (shouldFly(loc))
{