Luohuayu / CatServer

高性能和高兼容性的1.12.2/1.16.5/1.18.2版本Forge+Bukkit+Spigot服务端 (A high performance and high compatibility 1.12.2/1.16.5/1.18.2 version Forge+Bukkit+Spigot server)
https://catmc.org
GNU Lesser General Public License v3.0
1.98k stars 211 forks source link

[1.16.5]Problem using PlayerJoinEvent event to teleport a logged-in player to specified world coordinates #541

Closed Akita041 closed 2 years ago

Akita041 commented 2 years ago

JavaVersion: zulu8.64.0.15-ca-jdk8.0.342-win_x64

Minecraft Version: 1.16.5

Mods: none

Build version: CatServer version 1.16.5-d691d2f4 (MC: 1.16.5)

Describe the bug: When players enter the game and use PlayerJoinEvent to obtain players and transmit them, they are likely to be transmitted to an unknown space with the same coordinates

To Reproduce: Take a simple example,When using the following code to send a player logged into the game,Especially if the player goes offline in a world of a different dimension, and then when the player comes back online, it is likely to be teleported to an unknown world.

For example code as below:

  @EventHandler
  public void PlayerJoin(PlayerJoinEvent event){
        World world = Bukkit.getWorld("world");     /* The name of the world I want the player to teleport to after going online*/
        Location location = new Location(world,128,63,79);  /*I want the coordinates of the world to which the player is teleported after entering the game*/
        event.getPlayer().teleport(location);   /*complete teleport*/

  }

Expected behavior: A code similar to the above will send the player logged in to the game to an unknown space with a high probability, making the player overwhelmed

Akita041 commented 2 years ago

Delivery using PlayerJoinEvent requires delayed execution, solved, thank you