Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5043

Player not added to PlayerChunkMap/EntityTracker if world is changed in PlayerSpawnLocationEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • git-Spigot-baafee9-17543ec (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
    • Yes

      If the spawn location in PlayerSpawnLocationEvent is set to a location in a different world (than the player would have joined originally), the player is not added to the PlayerChunkMap/EntityTracker. This results in several issues e.g. entities don't despawn in the client, the inventory is not synced, you can't open elytras, the clients own metadata is not updated etc.

      This is a huge issue on our server network.

      Example plugin code (binary included as an attachment):

      public class TestPlugin extends JavaPlugin implements Listener {
         private World world;
      
         @Override
         public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
            world = Bukkit.createWorld(WorldCreator.name("test"));
         }
      
         @EventHandler
         public void onSpawnLocation(PlayerSpawnLocationEvent e) {
            Player player = e.getPlayer();
            System.out.println("spawn1: " + e.getSpawnLocation());
            if (e.getSpawnLocation().getWorld() == world) {
               e.setSpawnLocation(Bukkit.getWorld("world").getSpawnLocation());
            } else {
               e.setSpawnLocation(world.getSpawnLocation());
            }
            System.out.println("spawn2: " + e.getSpawnLocation());
         }
      }
      

            Unassigned Unassigned
            Gerrygames Gero Cammans
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: