Skip to content

Commit 4e6c98a

Browse files
committed
Allow people with god & fly to teleport to unsafe locations even when teleport safety is disabled.
1 parent a2c692a commit 4e6c98a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Essentials/src/com/earth2me/essentials/Teleport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws
102102
teleportee.setLastLocation();
103103
final Location loc = target.getLocation();
104104

105-
if (LocationUtil.isBlockUnsafe(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
105+
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
106106
{
107107
if (ess.getSettings().isTeleportSafetyEnabled())
108108
{

Essentials/src/com/earth2me/essentials/utils/LocationUtil.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,22 @@ static boolean isBlockAboveAir(final World world, final int x, final int y, fina
222222
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
223223
}
224224

225+
public static boolean isBlockUnsafeForUser(final IUser user, final World world, final int x, final int y, final int z)
226+
{
227+
if (user.getBase().isOnline() && world.equals(user.getBase().getWorld())
228+
&& (user.getBase().getGameMode() == GameMode.CREATIVE || user.isGodModeEnabled())
229+
&& user.getBase().getAllowFlight())
230+
{
231+
return false;
232+
}
233+
234+
if (isBlockDamaging(world, x, y, z))
235+
{
236+
return true;
237+
}
238+
return isBlockAboveAir(world, x, y, z);
239+
}
240+
225241
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
226242
{
227243
if (isBlockDamaging(world, x, y, z))
@@ -265,9 +281,9 @@ public static Location getRoundedDestination(final Location loc)
265281

266282
public static Location getSafeDestination(final IUser user, final Location loc) throws Exception
267283
{
268-
if (loc.getWorld().equals(user.getBase().getWorld())
269-
&& ((user.getBase().getGameMode() == GameMode.CREATIVE
270-
|| user.isGodModeEnabled()) && user.getBase().getAllowFlight()))
284+
if (user.getBase().isOnline() && loc.getWorld().equals(user.getBase().getWorld())
285+
&& (user.getBase().getGameMode() == GameMode.CREATIVE || user.isGodModeEnabled())
286+
&& user.getBase().getAllowFlight())
271287
{
272288
if (shouldFly(loc))
273289
{

0 commit comments

Comments
 (0)