2 Fawe TaskManager
Jesse Boyd edited this page 2016-11-02 04:06:38 +11:00

Async task

Pretty basic stuff, but this is how you run an async task with the FAWE TaskManager

TaskManager.IMP.async(new Runnable() {
    @Override
    public void run() {
        // Do stuff here?
    }
});

Sync task

With the FAWE TaskManager to you can switch to the main thread (from an async one) and run a task.

// Get a player's inventory from an async thread
// E.g. if the method isn't safe to use async
PlayerInventory inventory = TaskManager.IMP.sync(new RunnableVal<PlayerInventory>() {
    @Override
    public void run(PlayerInventory value) {
        this.value = player.getInventory();
    }
});

When to do this?

  • The method you want to call isn't safe to use async
  • The are performance issues with doing the task async