-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
None
-
This server is running CraftBukkit version git-Spigot-2040c4c-933e909 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
-
Yes
PlayerTeleportEvent gets fired after PlayerQuitEvent if the player is riding something like a pig. It does not get called if the player is not riding something.
The expected behavior is that this event does not get fired at all on logout.
Test plugin:
public class TestPlugin extends JavaPlugin implements Listener { @Override public void onEnable() { PluginManager manager = getServer().getPluginManager(); // Player join events manager.registerEvents(this, this); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerJoin(final PlayerQuitEvent e) { Bukkit.getLogger().info("Player Quit event"); Bukkit.getLogger().info("Player in vehicle = " + e.getPlayer().isInsideVehicle()); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void wearingElytra(PlayerTeleportEvent e) { Bukkit.getLogger().info("Player Teleport event cause " + e.getCause()); Bukkit.getLogger().info("Player in vehicle = " + e.getPlayer().isInsideVehicle()); } }
Log in and create a pig with a saddle. Ride it and log out. The output from the console is:
[14:15:35] [Server thread/INFO]: tastybento lost connection: Disconnected [14:15:35] [Server thread/INFO]: Player Quit event [14:15:35] [Server thread/INFO]: Player in vehicle = true [14:15:35] [Server thread/INFO]: Player Teleport event cause UNKNOWN [14:15:35] [Server thread/INFO]: Player in vehicle = false [14:15:35] [Server thread/INFO]: tastybento left the game
I use the PlayerQuitEvent to clear a load of caches, but the TeleportEvent is then putting the player back. The player still reads as online during the event, so there's no way to trap the offline nature unless I put some complex flags in there.
It looks like the player is being dismounted from the vehicle in the teleport event, but when the player logs back in, they are still mounted, so the inVehicle state is also wrong.
Thanks for looking at this!