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(AsyncCatcher.java:14) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.World.b(World.java:2633) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.Chunk.addEntities(Chunk.java:820) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:49) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:1) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:337) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:295) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:16) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:115) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:97) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.createWorld(CraftServer.java:929) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.createWorld(Bukkit.java:464) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at rmc.raypixel.skywars.game.object.Game.<init>(Game.java:50) ~[?:?]
            at rmc.raypixel.skywars.game.RaypixelSkywarsGame.onEnable(RaypixelSkywarsGame.java:58) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:576) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at rmc.raypixel.skywars.game.RaypixelSkywarsGame$1.run(RaypixelSkywarsGame.java:279) [Raypixel-SkywarsGame.jar:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_171]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_171]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    Line 49 and 50 in Game:
    Code (Java):
    49 this.world = 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):

    #!/bin/sh
    export LC_ALL=C
    while (true)
    do
    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
    do
    echo "$i..."
    sleep 1
    done
    echo "Restarting The Server!"
    done
     
     
  10. Thanks. But all plugins on the server work fine with /reload.