EssentialsX

EssentialsX

2M Downloads

/home command triggers PlayerRespawnEvent

Worf2340 opened this issue ยท 2 comments

commented

Information

Full output of /ess version:

[14:56:56 INFO]: EssentialsX version: 2.17.0.0
[14:56:56 INFO]: LuckPerms version: 4.4.1
[14:56:56 INFO]: Vault is not installed. Chat and permissions may not work.

Server log: https://gist.github.com/Worf2340/b0adef4d06736b8a19500c6cbeb7d906

EssentialsX config: https://gist.github.com/Worf2340/ec699b584bdbc04be94474f9c9f82a26

Details

Description
Having a player who does /home with no bed spawn point or homes set triggers PlayerRespawnEvent.

Steps to reproduce
Have a player who has no bed spawn point or homes set run the /home command. I also had a plugin setup to output a message to console when the PlayerRespawnEvent was called.

Looking at Commandhome.java, I found user.getTeleport().respawn(charge, TeleportCause.COMMAND); on line 56.
Following that function led me to lines 278 and 279 of Teleport.java:
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
ess.getServer().getPluginManager().callEvent(pre);

Expected behavior
Not call the PlayerRespawnEvent. It interferes with the behavior of other plugins which use the PlayerRespawnEvent by creating a false positive event.

commented

Essentials has always fired this event when a player respawns, so I don't see how this is a false positive.

The event is fired when EssentialsX simulates a vanilla respawn (teleporting a player to either their bed or the spawn point). Off the top of my head, this happens in the following instances:

  • /spawn (when Spawn is installed)
  • /home without any homes set (functionally identical to /spawn)
  • Leaving jail when unjailed
  • Probably some other cases I've missed

The original reason for this is to allow other plugins to intercept this to change standard respawn behaviour, just like they can with vanilla respawns.

As this has been standard behaviour for well over 7 years, I don't see a reason to change this.

commented

Ah ok, well thank you for explaining it to me. The reason that I described it as a false positive was due to an old plugin I am updating using the respawn event to check for a player death, so the /home command caused it to fire incorrectly.

However, I can update that plugin to use the player death event instead, which should eliminate the problem.