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

Can't modify chunk in ChunkUnloadEvent

XMLWordPrintable

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

      When trying to set a block in a chunk that is currently being unloaded (in the ChunkUnloadEvent) a ConcurrentModificatioException is thrown. I guess this is due to the chunk being unmarked as unloadable. The server did not crash when I tested on a local server. However I saw servers crashing due to this issue.

      Exception in the console:

      http://paste.cytooxien.de/cejifijifi.rb

      Example plugin code (binary included as an attachment):

      import org.bukkit.Bukkit;
      import org.bukkit.Material;
      import org.bukkit.World;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.world.ChunkUnloadEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public class TestPlugin extends JavaPlugin implements Listener {
      
         @Override
         public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
         }
      
         @EventHandler
         public void onChunkUnload(ChunkUnloadEvent e) {
            Bukkit.broadcastMessage("unload " + e.getChunk().getX() + "/" + e.getChunk().getZ());
            World world = e.getWorld();
            world.getBlockAt(e.getChunk().getX() >> 4, 100, e.getChunk().getZ() >> 4).setType(Material.GLASS);
         }
      }

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

              Created:
              Updated:
              Resolved: