Updated TaskBuilder (markdown)

Jesse Boyd 2016-11-02 04:05:02 +11:00
parent 6e47884b40
commit 77264b10a3

@ -23,12 +23,13 @@ new TaskBuilder()
### SplitTask example ### SplitTask example
Split up a task and run it when the main thread is free. Split up a task and run it when the main thread is free.
```Java ```Java
//In reality you'd use one of FAWE's async world manipulators (EditSession, AsyncWorld, FaweQueue etc.) // In reality you'd use one of EditSession, AsyncWorld, FaweQueue instead.
// But this is just an example of how you can split up a task with the FAWE API // But this is just an example of how you can split up a task with the FAWE API
final World world = Bukkit.getWorld("world"); final World world = Bukkit.getWorld("world");
new TaskBuilder() new TaskBuilder()
.syncWhenFree(new TaskBuilder.SplitTask(20) { // Execution will be split into multiple 20ms tasks // Execution will be split into multiple 20ms tasks
.syncWhenFree(new TaskBuilder.SplitTask(20) {
@Override @Override
public Object exec(Object previous) { public Object exec(Object previous) {
for (int x = 0; x < 100; x++) { for (int x = 0; x < 100; x++) {
@ -36,6 +37,7 @@ new TaskBuilder()
for (int z = 0; z < 100; z++) { for (int z = 0; z < 100; z++) {
world.getBlockAt(x, y, z).setType(Material.STONE); world.getBlockAt(x, y, z).setType(Material.STONE);
// FAWE will use this point to split the task // FAWE will use this point to split the task
// You can have multiple split points
split(); split();
} }
} }