Skip to content

Commit ae0e4a8

Browse files
committed
Handle feedback. Part of the documentation has been deleted and the content has been simplified and made more concrete
1 parent ab9333f commit ae0e4a8

File tree

1 file changed

+27
-51
lines changed

1 file changed

+27
-51
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Filling a region using a pattern
22

33
## Foreword
4-
First of all, patterns usually come from the core part of Worleedit or FAWE. The patterns can be found in the following path: [worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern](https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/com/fastasyncworldedit/core/extension/factory/parser/pattern/package-summary.html)
5-
6-
_The link refers you to the JavaDocs with the correct package_
7-
8-
In this example, we only refer to one pattern for the time being.
4+
First of all, patterns usually come from the core part of WorldEdit or FAWE. You can find all existing patterns [here](https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/com/sk89q/worldedit/function/pattern/Pattern.html)
95

106
## Biome Cuboid Example
117
Given are 3 things:
@@ -14,65 +10,45 @@ Given are 3 things:
1410
- BiomeType: Badlands
1511

1612
```java
17-
// Here we must first adapt the world as in the WorldEdit example or translate it into the WorldEdit specialized object.
18-
World faweWorld = BukkitAdapter.adapt(world);
19-
20-
// Here we set our position 1 and 2
21-
BlockVector3 position1 = BlockVector3.at(300,-64,300);
22-
BlockVector3 position2 = BlockVector3.at(600,128,600);
23-
24-
//Now we define a square region using our 2 positions
25-
CuboidRegion cuboidRegion = new CuboidRegion(position1, position2);
26-
27-
// Now we open an EditSession, which contains the complete process or information during an edit process in the world. Through the try-and-catch-with-resources we let Java automatically close the resource EditSession after use
28-
try (EditSession editSession = WorldEdit.getInstance().newEditSession(faweWorld)) {
29-
// Here we create our biome pattern
30-
var pattern = new BiomeApplyingPattern(editSession, BiomeTypes.BADLANDS);
31-
32-
//This sets the pattern to the region
33-
editSession.setBlocks((Region) cuboidRegion, pattern);
34-
}
35-
```
36-
_This code is still Fawe unspecific and can also be used in WorldEdit in this way_
13+
public void setBiomeArea(World world, BlockVector3 position1, BlockVector3 position 2) {
14+
// Here we must first adapt the world as in the WorldEdit example or translate it into the WorldEdit specialized object.
15+
World faweWorld = BukkitAdapter.adapt(world);
3716

38-
### Let's set blocks async with FAWE
39-
{% hint style="info" %}
40-
**Recommended**
17+
//Now we define a square region using our 2 positions
18+
CuboidRegion cuboidRegion = new CuboidRegion(position1, position2);
4119

42-
If no plug-in instance is available, you can also use the Task Manger. See below
43-
{% endhint %}
44-
Now we run the code Async to let Fawe manage server resources:
45-
```java
46-
// Now we wrap our code in a runnable with a functional interface and have it executed by Bukkit's scheduler system
47-
Runnable executeCode = () -> {
48-
// Now we open an EditSession, which contains the complete process or information during an edit process in the world. Through the try-and-catch-with-resources we let Java automatically close the resource EditSession after use
20+
// Now we open an EditSession, which contains the complete process or information during an edit process in the world.
21+
// Through the try-and-catch-with-resources we let Java automatically close the resource EditSession after use
4922
try (EditSession editSession = WorldEdit.getInstance().newEditSession(faweWorld)) {
5023
// Here we create our biome pattern
5124
var pattern = new BiomeApplyingPattern(editSession, BiomeTypes.BADLANDS);
52-
25+
5326
//This sets the pattern to the region
5427
editSession.setBlocks((Region) cuboidRegion, pattern);
5528
}
56-
};
57-
Bukkit.getScheduler().runTask(Bukkit.getPluginManager().getPlugin("YourPluginNameHere"), executeCode);
29+
}
30+
// This code would be called by the plugin in the main thread
31+
public void call() {
32+
// Here we set our position 1 and 2
33+
BlockVector3 position1 = BlockVector3.at(300,-64,300);
34+
BlockVector3 position2 = BlockVector3.at(600,128,600);
35+
World bukkitWorld = Bukkit.geWorld("world");
36+
setBiomeArea(bukkitWorld, position1, position2);
37+
}
5838
```
39+
_This code is still Fawe unspecific and can also be used in WorldEdit in this way_
5940

60-
---
61-
62-
We can also use the TaskManger from Fawe. To do this, we only need to replace a call.
63-
41+
### Let's set blocks async with FAWE
6442

43+
Now we run the code Async to let Fawe manage server resources:
6544
```java
6645
// Now we wrap our code in a runnable with a functional interface and have it executed by Bukkit's scheduler system
6746
Runnable executeCode = () -> {
68-
// Now we open an EditSession, which contains the complete process or information during an edit process in the world. Through the try-and-catch-with-resources we let Java automatically close the resource EditSession after use
69-
try (EditSession editSession = WorldEdit.getInstance().newEditSession(faweWorld)) {
70-
// Here we create our biome pattern
71-
var pattern = new BiomeApplyingPattern(editSession, BiomeTypes.BADLANDS);
72-
73-
//This sets the pattern to the region
74-
editSession.setBlocks((Region) cuboidRegion, pattern);
75-
}
47+
// Here we set our position 1 and 2
48+
BlockVector3 position1 = BlockVector3.at(300,-64,300);
49+
BlockVector3 position2 = BlockVector3.at(600,128,600);
50+
World bukkitWorld = Bukkit.geWorld("world");
51+
setBiomeArea(bukkitWorld, position1, position2);
7652
};
77-
TaskManager.taskManager().taskNow(executeCode, true); // The second parameter specifies whether it should run async or sync.
53+
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("YourPluginNameHere"), executeCode);
7854
```

0 commit comments

Comments
 (0)