EssentialsX

EssentialsX

2M Downloads

getTeleporter() returns wrong player for /tphere

BloodEko opened this issue ยท 1 comments

commented

Type of bug

Compatibility issue

/ess dump all output

https://essentialsx.net/dump.html?id=a9195a029a124921a836af060711c239

Error log (if applicable)

No response

Bug description

When running /tphere on a player the TeleportWarmupEvent will have getTeleporter() and getTeleportee() returning the same, teleported player, instead of different players.

https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/main/java/net/ess3/api/events/teleport/TeleportEvent.java#L31
The problem seems to be caused by the shorthand constructor, which doesn't distinguish the fields.
So there might be more commands affected, which should be checked.

Steps to reproduce

  1. Have a least 2 people online.
  2. Teleport the other player via /tphere
  3. Via the output for the code below.
@EventHandler
public void onWarmup(TeleportWarmupEvent event) {
    System.out.println("Teleporter: " + event.getTeleporter());
    System.out.println("Teleportee: " + event.getTeleportee());
}

Expected behaviour

For the event getTeleporter() should return the caller of the command.

Actual behaviour

For the event getTeleporter() returns the target of the command.

commented

Looks like this is a regression that was introduced in AsyncTeleport#teleportOther, the logic in Teleport#teleportOther appears to use the correct event call.