7 AsyncWorld
Jesse Boyd edited this page 2018-03-01 15:38:38 +11:00

The AsyncWorld implements the Bukkit World interface and allows you to asynchronously access or make changes to the world.

  • Most objects obtained from an instance can be used async (location, block, chunk etc.)
  • Only block and biome manipulation is optimized for the queue
  • Other operations will be slower when used async
  • You can use AsyncWorld.create(...) to load a world async

Note: The AsyncWorld class is only present in FastAsyncWorldEdit-bukkit, not the API.

TaskManager.IMP.async(new Runnable() {
    @Override
    public void run() {
        // Create or load a world async with the provided WorldCreator settings
        AsyncWorld world = AsyncWorld.create(new WorldCreator("MyWorld"));
        // AsyncWorld world = AsyncWorld.wrap(bukkitWorld); // Or wrap existing world
        Block block = world.getBlockAt(0, 0, 0);
        block.setType(Material.BEDROCK);
        // When you are done
        world.commit();
    }
});

Source: https://github.com/boy0001/FastAsyncWorldedit/blob/master/bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java#L66

Notes on async performance

https://github.com/boy0001/FastAsyncWorldedit/wiki/Notes-on-async-performance And: https://github.com/boy0001/FastAsyncWorldedit/wiki/Fawe-TaskManager#sync-task