TheNextLvlTheNextLvl

API

The API documentation for the Worlds plugin.

GitHub Edit on GitHub

Javadocs for the API can be found here.

Getting Started

To get started with the API, you have to retrieve the WorldsProvider from the service manager:

WorldsProvider provider = Bukkit.getServiceManager().load(WorldsProvider.class);

Creating a World

To create a world, you can use the Level.Builder which offers a fluent API to configure the world:

Level level = provider.levelBuilder(Path.of("New World (1)")) // the path the world will be stored at
        .key(Key.key("worlds", "my_new_world")) // world key (used by client and server to identify worlds)
        .name("My New World") // the user friendly name for the world
        .seed(9873425983045299341L) // the world seed
        .spawnChunkRadius(2) // the spawn chunk radius
        .hardcore(false) // whether the world is in hardcore mode
        .bonusChest(true) // generate a starter chest at spawn
        .structures(false) // control if structures generate
        .preset(Presets.THE_VOID) // define a flat world preset (aka. world settings)
        .generator(Generator.of(provider, "PlotSquared")) // define a custom generator
        .generatorType(GeneratorType.SINGLE_BIOME) // set the generator type (aka. world type)
        .levelStem(LevelStem.OVERWORLD) // set the level stem (aka. environment)
        .build();

level.createAsync().thenAccept(world -> {
    // world created successfully
}).exceptionally(throwable -> {
    // world creation failed
    return null;
});

Cloning a World

Cloning a world was never easier. You can use the LevelView#cloneAsync method.

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

CompletableFuture<World> future = provider.levelView().cloneAsync(world, builder -> {
    // optionally configure the cloned world
    builder.key(Key.key("worlds", "my_cloned_world")); // set the key for the cloned world
    builder.name("My Cloned World"); // set the name for the cloned world
}, full);

future.thenAccept(clone -> {
    // cloned world created successfully
}).exceptionally(throwable -> {
    // cloning failed
    return null;
});

Last updated on