Solved ERROR: Asynchronous entity world add

Discussion in 'Spigot Plugin Development' started by SiderRMC, Jul 18, 2018.

  1. Error occurred while enabling my skywars plugin for subservers.

    Code (Text):
    [22:29:06 ERROR]: Error occurred while enabling Raypixel-SkywarsGame v1.0 (Is it up to date?)
    java.lang.IllegalStateException: Asynchronous entity world add!
            at org.spigotmc.AsyncCatcher.catchOp( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.World.b( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.Chunk.addEntities( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOProvider.callStage2( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOProvider.callStage2( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.util.AsynchronousExecutor.skipQueue( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.util.AsynchronousExecutor.getSkipQueue( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOExecutor.syncChunkLoad( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.createWorld( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.createWorld( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at<init>( ~[?:?]
            at ~[?:?]
            at ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.dispatchCommand( [spigot.jar:git-Spigot-db6de12-18fbb24]
            at$ [Raypixel-SkywarsGame.jar:?]
            at [spigot.jar:git-Spigot-db6de12-18fbb24]
            at [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_171]
            at java.util.concurrent.ThreadPoolExecutor$ Source) [?:1.8.0_171]
            at Source) [?:1.8.0_171]
    Line 49 and 50 in Game:
    Code (Java):
    49 = Bukkit
    50                 .createWorld(new WorldCreator(fileConfiguration.getString("games." + gameName + ".world") + "_active"));
  2. Says it right there, trying to create a world off the main thread. Solution, Bukkit.getSchedular().runTask(plugin, () -> {/* my code */})
    • Like Like x 1
  3. md_5

    Administrator Developer

    Its not that, you or another plugin used an async task to execute /reload
    Which is really bad
  4. The error is telling you that a plugin is trying to add an entity to the world asynchronously. This is done through a BukkitRunnable. remove the Asynchronous bukkit runnable and replace it with run task

    Ooops my bad did not read through all the stack trace
    Yeah what @md_5 said :)
  5. Skywars subservers need to restart after the game ends. Except /reload, what else can I do?
  6. md_5

    Administrator Developer

    Dont reload async
  7. I changed it to scheduleSyncDelayedTask, and it now works perfectly. Thanks.
    Code (Java):
    public void reloadAfter100() {

            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                public void run() {
                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "reload");
            }, 100);

  8. Better don’t reload at all. Stop or restart. Many plugins can’t handle reloads.
  9. If you have any plugins on your servers that handle reloads improperly, you're opening yourself up to a whole world of hurt. Memory leaks being one of many.

    Set up a startup script to constantly start the server, then STOP the server with your plugin. The script will run, and the server will start back up. Assuming you don't have too many plugins, startup time shouldn't be too much of an issue.

    Here is the start script I use:
    Code (Text):

    export LC_ALL=C
    while (true)
    java -server -Xmx1G -Xms512M -XX:+UseG1GC -jar paper.jar
    echo "Server is restarting. Enter Ctrl + C to kill the server!"
    echo "Restarting In:"
    for i in 5 4 3 2 1
    echo "$i..."
    sleep 1
    echo "Restarting The Server!"
  10. Thanks. But all plugins on the server work fine with /reload.