EssentialsX

EssentialsX

2M Downloads

[BUG] setting teleport-safety: false with a warm-up for teleport does NOT show an erroe message when the location is unsafe

TomLewis opened this issue ยท 2 comments

commented

Information

Server version: 1.12.2-R0.1-SNAPSHOT git-Paper-1589 (MC: 1.12.2)
2018-12-03 20:24:25 | EssentialsX version: 2.15.0.45
2018-12-03 20:24:25 | LuckPerms version: 4.3.2
2018-12-03 20:24:25 | Vault version: 1.6.6-b${env.TRAVIS_BUILD_NUMBER}
2018-12-03 20:24:25 | EssentialsXChat version: 2.15.0.45
2018-12-03 20:24:25 | EssentialsXGeoIP version: 2.15.0.45
2018-12-03 20:24:25 | EssentialsXSpawn version: 2.15.0.45

All teleport config variables:

# If the teleport destination is unsafe, should players be teleported to the nearest safe location?
# If this is set to true, Essentials will attempt to teleport players close to the intended destination.
# If this is set to false, attempted teleports to unsafe locations will be cancelled with a warning.
teleport-safety: false

# This forcefully disables teleport safety checks without a warning if attempting to teleport to unsafe locations.
# teleport-safety and this option need to be set to true to force teleportation to dangerous locations.
force-disable-teleport-safety: false

# The delay, in seconds, required between /home, /tp, etc.
teleport-cooldown: 60

# The delay, in seconds, before a user actually teleports.  If the user moves or gets attacked in this timeframe, the teleport never occurs.
teleport-delay: 5

# The delay, in seconds, a player can't be attacked by other players after they have been teleported by a command.
# This will also prevent the player attacking other players.
teleport-invulnerability: 0

# Whether to make all teleportations go to the center of the block; where the x and z coordinates decimal become .5
teleport-to-center: true

Details

Description
If you have teleport-safety: false and teleport-delay: 5, no error message is sent to the user if their /sethome is unsafe and set inside a block. If the player bypasses teleport-delay they will get the error message.

Expected behavior
To show the error message, instead of just getting stuck on "Teleport commencing"

Screenshot
https://cdn.discordapp.com/attachments/515887781369872395/519245048622088193/unknown.png

commented

Thanks for taking the time to file this bug report!


If a location is unsafe, we throw an exception in the Teleport class:

if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {
teleportee.getBase().teleport(loc, cause);
} else {
teleportee.getBase().teleport(LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
}
} else {
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
} else {

When there isn't a delay, this is fine: the /home command catches this and sends the message to the user.

However, when there is a delay, the teleport is handled by a TimedTeleport task and not the command. TimedTeleport inexplicably ignores the unsafe location error (wtf?):

try {
cancelTimer(false);
teleportUser.sendMessage(tl("teleportationCommencing"));
try {
if (timer_chargeFor != null) {
timer_chargeFor.isAffordableFor(teleportOwner);
}
if (timer_respawn) {
teleport.respawnNow(teleportUser, timer_cause);
} else {
teleport.now(teleportUser, timer_teleportTarget, timer_cause);
}
if (timer_chargeFor != null) {
timer_chargeFor.charge(teleportOwner);
}
} catch (Exception ex) {
}
} catch (Exception ex) {
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
}

Note how lines 114-115 are an empty catch clause, which is the reason the unsafe location error is ignored.


I haven't had a chance to dig through to see if there's an actual reason for this, but removing the second try/catch should resolve this.

commented

This should be fixed in the latest dev builds, which refactor EssentialsX's teleports to support Paper's async teleportation and improves teleport timer handling. You can download dev builds from the EssentialsX website.