Skip to content

Commit 1c34144

Browse files
committed
fix(docs): update world creation and cloning examples to use asynchronous methods
1 parent 7281031 commit 1c34144

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

content/docs/worlds/api/index.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,32 @@ Level level = provider.levelBuilder(Path.of("New World (1)")) // the path the wo
3939
.levelStem(LevelStem.OVERWORLD) // set the level stem (aka. environment)
4040
.build();
4141

42-
level.create().ifPresentOrElse(world -> {
42+
level.createAsync().thenAccept(world -> {
4343
// world created successfully
44-
}, () -> {
44+
}).exceptionally(throwable -> {
4545
// world creation failed
46+
return null;
4647
});
4748
```
4849

4950
## Cloning a World
5051

51-
Cloning a world was never easier. You can use the <a href={docsClass.replace("%s.html", "view/LevelView.html#clone(org.bukkit.World,java.util.function.Consumer,boolean)")} target="\_blank">LevelView#clone</a>
52+
Cloning a world was never easier. You can use the <a href={docsClass.replace("%s.html", "view/LevelView.html#cloneAsync(org.bukkit.World,java.util.function.Consumer,boolean)")} target="\_blank">LevelView#cloneAsync</a>
5253
method.
5354

5455
```java
5556
boolean full = true; // whether to fully clone including regions, entities..., or only the level.dat
5657

57-
Optional<World> clone = provider.levelView().clone(world, builder -> {
58+
CompletableFuture<World> future = provider.levelView().cloneAsync(world, builder -> {
5859
// optionally configure the cloned world
5960
builder.key(Key.key("worlds", "my_cloned_world")); // set the key for the cloned world
6061
builder.name("My Cloned World"); // set the name for the cloned world
6162
}, full);
63+
64+
future.thenAccept(clone -> {
65+
// cloned world created successfully
66+
}).exceptionally(throwable -> {
67+
// cloning failed
68+
return null;
69+
});
6270
```

0 commit comments

Comments
 (0)