1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Bug Chunk load events not being called

Discussion in 'Bugs & Feature Requests' started by Jarcode, Jun 14, 2015.

  1. The infamous bug from a while back when chunk load events were inconsistent. Looks like it happening again, but only when the player spawns in unloaded chunks.

    Test case:
    Code (Text):

        @EventHandler
        public void onChunkLoad(ChunkLoadEvent e) {
            Chunk chunk = e.getChunk();
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getOnlinePlayers().stream()
                    .forEach(player -> {
                        Chunk at = player.getLocation().getChunk();
                        if (at.getX() == chunk.getX() && at.getZ() == chunk.getZ())
                            logger.info("LOADED PLAYER CHUNK");
                    }), 40L);
        }
    When spawning into a part of the world where the chunks are unloaded (you can track this similarly with chunk unload events, which seem to work fine), you do not see 'LOADED PLAYER CHUNK' with this event registered. I used a 40 tick delay to ensure that the player would have joined the server by the time we check if the load event corresponds with the chunk the player belongs to.

    If you use a similar check on a particular chunk to see if it is being loaded/unloaded when a player walks in and out of its render distance, it works fine.

    If you attempt the above test case, make sure you are testing it away from the spawn chunks.