mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-26 09:21:55 +01:00
Created API Usages (markdown)
parent
ab50fc1f54
commit
abb695ad07
38
API-Usages.md
Normal file
38
API-Usages.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
This pages provides examples and explanation for the common API usages of Multiverse-Core introduced [here](Developer-API-Starter). It's impossible to cover all API methods in this guide, but rest assured we have [javadocs](http://ci.onarandombox.com/job/Multiverse-Core/javadoc/overview-summary.html) and [source code](https://github.com/Multiverse/Multiverse-Core/tree/main/src/main/java/com/onarandombox/MultiverseCore/api) provided.
|
||||||
|
|
||||||
|
## [MVWorldManager](http://ci.onarandombox.com/job/Multiverse-Core/javadoc/com/onarandombox/MultiverseCore/api/MVWorldManager.html)
|
||||||
|
The MVWorldManager interface is the heart of managing worlds in Multiverse. You can use various methods in this class to create, delete, regen worlds and much more!
|
||||||
|
|
||||||
|
### Getting the WorldManager instance
|
||||||
|
```java
|
||||||
|
MVWorldManager worldManager = core.getMVWorldManager();
|
||||||
|
```
|
||||||
|
If you are unsure of getting the Multiverse-Core instance, see [here](Developer-API-Starter#getting-the-multiverse-plugin-instances).
|
||||||
|
|
||||||
|
### Creating a world
|
||||||
|
Lets now create a new overworld called `creative`.
|
||||||
|
```java
|
||||||
|
worldManager.addWorld(
|
||||||
|
"creative", // The worldname
|
||||||
|
World.Environment.NORMAL, // The overworld environment type.
|
||||||
|
null, // The world seed. Any seed is fine for me, so we just pass null.
|
||||||
|
WorldType.NORMAL, // Nothing special. If you want something like a flat world, change this.
|
||||||
|
true, // This means we want to structures like villages to generator, Change to false if you don't want this.
|
||||||
|
null // Specifies a custom generator. We are not using any so we just pass null.
|
||||||
|
);
|
||||||
|
```
|
||||||
|
Things to note:
|
||||||
|
* World names follow the Bukkit API's [`NamespacedKey`](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/NamespacedKey.html), which means it does not allow spaces or special characters.
|
||||||
|
|
||||||
|
### Loading/Unloading a world
|
||||||
|
You may want to unload worlds when unused and load them back when it's needed.
|
||||||
|
```java
|
||||||
|
// unloading
|
||||||
|
worldManager.unloadWorld("creative");
|
||||||
|
|
||||||
|
// loading
|
||||||
|
worldManager.loadWorld("creative");
|
||||||
|
```
|
||||||
|
Things to note:
|
||||||
|
* You cannot unload the default world defined in `level-name` of `server.properties`.
|
||||||
|
* You can only load worlds that are known by Multiverse, use the `MVWorldManager#addWorld` method mentioned previously.
|
Loading…
Reference in New Issue
Block a user