1. The latest Spigot and BungeeCord builds have been updated to include support for Minecraft versions 1.7.2, 1.7.5, 1.7.6, 1.7.7 and the newly released 1.7.8. In order to enable this support all you need to do is to update to at least Spigot build #1387 and BungeeCord build #883.
    Additionally Spigot builds #1388 and above are full builds, not just protocol updates. Please note that these builds are still in development and quite unstable, as such staying on #1387 may be beneficial. When using these builds backups are very important as 1.7.8 makes PERMANENT changes to the way player data is stored.

Asynchronous entity add!

Discussion in 'Plugin Development' started by Craftiii4, Jul 14, 2013.

  1. I'm getting the following error (only on spigot builds);

    Code (text):
    2013-07-14 09:39:41 [SEVERE] Exception in thread "Craft Scheduler Thread - 0"
    2013-07-14 09:39:41 [SEVERE] org.apache.commons.lang.UnhandledException: Plugin [Plugin-name] v1.0.0 generated an exception while executing task 5
        at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.IllegalStateException: Asynchronous entity world add!
        at net.minecraft.server.v1_6_R2.World.a(World.java:2481)
        at net.minecraft.server.v1_6_R2.Chunk.addEntities(Chunk.java:683)
        at net.minecraft.server.v1_6_R2.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:128)
        at net.minecraft.server.v1_6_R2.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:84)
        at org.bukkit.craftbukkit.v1_6_R2.CraftWorld.getChunkAt(CraftWorld.java:119)
        at org.bukkit.craftbukkit.v1_6_R2.CraftWorld.getBlockAt(CraftWorld.java:83)
        at org.bukkit.craftbukkit.v1_6_R2.CraftWorld.getBlockAt(CraftWorld.java:485)
        at org.bukkit.Location.getBlock(Location.java:82)
        at me.craftiii4.[Plugin-name].Nation.StartCapture.ChangeFlag(StartCapture.java:42)
        at me.craftiii4.[Plugin-name].Player.AddAndRemove$2.run(AddAndRemove.java:178)
        at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftTask.run(CraftTask.java:58)
        at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
        ... 3 more
    On this line here;

    Code (text):
    while (locationoffirstwool.getBlock().getType() != Material.WOOL && locationoffirstwool.getY() <= 255) {
    The code around it is;

    Code (text):

    public static void ChangeFlag(String nation, final Location locationofsponge) {
    Location locationoffirstwool = locationofsponge;
        while (locationoffirstwool.getBlock().getType() != Material.WOOL && locationoffirstwool.getY() <= 255) {
            locationoffirstwool.add(0, 1, 0);
    This is called from a AsynTask, which is what is causing the error, but I fail to see why this is causing the error it is causing?

    Any help would be appreciated thanks.
  2. Switch the order of the statements in the while loop. Y gets incremented to 256 and then the block is checked before it is checked to be <= 255.
  3. Run the actual setting of the wool in a sync method. Spigot is saving your server. Editing the world like such in an asynchronous thread will corrupt the world.
    • Like Like x 1
  4. Thanks, I will try these once I get back.