Skip to main content

3. Management & Control

The IWorldManager manages all worlds, while the IManageableWorld object allows control over a specific world.

Retrieve worlds

// Retrive a single world
Optional<IManageableWorld> worldOpt = worldManager.getWorld("Lobby");

// Retrive all worlds
List<IManageableWorld> allWorlds = worldManager.getWorlds();

World actions

Each IManageableWorld object provides methods for control:

Method

Description

loadMap()

Loads the world from the hard drive (Bukkit World Init).

unloadMap()

Unloads the world and teleports players to the main spawn.

deleteMap()

Irrevocably deletes the world (files & database entry).

reCreate(boolean save)

Deletes the world and regenerates it (reset). Optionally with backup (true) or without (false).

clone(String name)

Creates a copy of the world under a new name.

Example: Performing a world reset

worldManager.getWorld(“Farmworld”).ifPresent(world -> {
    // Reset world and keep copy of old world
    world.reCreate(true); 
});

Example: Remove world (from the system)

If you want to remove a world from GWorld (including deleting the files):

// Option A: Directly via the object (recommended)
world.deleteMap();

// Option B: Over the manager
worldManager.removeWorld(world);