API Usages - Multiverse/Multiverse-Core GitHub Wiki

This pages provides examples and explanation for the common API usages of Multiverse-Core introduced here. It's impossible to cover all API methods in this guide, but rest assured we have javadocs provided.

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

MVWorldManager worldManager = core.getMVWorldManager();

If you are unsure of getting the Multiverse-Core instance, see here.

Creating a world

Lets now create a new overworld called creative.

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, 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.

// 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.

Deleting a world

The world is no longer of use? you can delete it with a simple API method.

This method will do 3 things:

  1. Unload the world.
  2. Remove world from config.
  3. Delete world folder completely.
worldManager.deleteWorld("uselessworld");

Things to note:

  • You cannot undo this action or restore the world back.
  • You can only delete worlds that can be loaded by the server.
  • If the world folder has been deleted, use MVWorldManager#removeWorldFromConfig method.

A class on top of the Bukkit's World object to provide additional world management features. This may also be used in methods of the other Multiverse modules.

Getting a MultiverseWorld instance

With the world manager you have earlier, we can use that to get a MultiverseWorld.

MultiverseWorld creativeWorld = world.getMVWorld("creative");

Changing GameMode property

Since this is a creative world, we want people to be set to creative mode when entering the world.

creativeWorld.setGameMode(GameMode.CREATIVE);

Things to note:

  • This can be bypassed with mv.bypass.gamemode.WORLDNAME permission node.
  • This doesn't not restrict the use of minecraft /gamemode (if you have the perms for it), just an enforcement upon entering a world.

Modifying and getting world alias

World alias allows you to display the world to players with fancy colours and styles.

Setting alias:

creativeWorld.setAlias("&cCreative Wonder");

Sending alias to a player.

public void tellMeWhereAmI(MultiverseWorld world, Player player) {
    String worldAlias = world.getColoredWorldString();
    player.sendMessage("You are at " + worldAlias);
}
⚠️ **GitHub.com Fallback** ⚠️