EssentialsX

EssentialsX

2M Downloads

PlayerRespawnEvent is called even if UserTeleportEvent has been canceled

BoomEaro opened this issue · 1 comments

commented

Information

Full output of /ess version:

[21:59:20] [Server thread/INFO]: Server версия: 1.12.2-R0.1-SNAPSHOT git-Paper-1615 (MC: 1.12.2)
[21:59:20] [Server thread/INFO]: EssentialsX версия: 2.17.2.144
[21:59:20] [Server thread/INFO]: LuckPerms версия: 5.0.118
[21:59:20] [Server thread/INFO]: Vault версия: 1.5.6-b49
[21:59:20] [Server thread/INFO]: Citizens версия: 2.0.26-SNAPSHOT (build 1861)
[21:59:20] [Server thread/INFO]: EssentialsXChat версия: 2.17.2.144
[21:59:20] [Server thread/INFO]: EssentialsXSpawn версия: 2.17.2.144

Server log: not needed

EssentialsX config: not needed

Details

Description
It looks like PlayerRespawnEvent is called even if UserTeleportEvent is canceled.

Steps to reproduce

  1. Write a simple plugin that listens to the PlayerRespawnEvent and UserTeleportEvent events.
  2. Always cancel the UserTeleportEvent event.
  3. As an example of teleportation, use the /home command.
  4. Make sure that you do not have a single house created by the /sethome command.
  5. Try using /home with no arguments. (logically, you will have to teleport to spawn, but the UserTeleportEvent event is canceled, however, PlayerRespawnEvent is still called, although the player was not even moved to the spawn point)

Expected behavior
In my opinion, PlayerRespawnEvent should not be called if the player was not really teleported.

Screenshots
none

The problem is that the PlayerRespawnEvent event is called before teleportation processing is called:

final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);

commented

While you are correct that PlayerRespawnEvent probably shouldn't be called, the reason it's called by Essentials is to hook into other plugins (include Essentials itself) which modify the spawn location. This is an old behavior that has been in Essentials for a long time which is why changing it would be breaking. Additionally, it would require a refactor of the Teleport code I just refactored 😅

For those reasons, closed for wonfix.