Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 1.03 KB

load-world.md

File metadata and controls

25 lines (21 loc) · 1.03 KB

Loading a world

First, retrieve the SwoftyWorldManager plugin API:

SlimePlugin plugin = (SlimePlugin) Bukkit.getPluginManager().getPlugin("SwoftyWorldManager");

Now, you need a loader. A SlimeLoader is a class that reads and stores worlds from a data source. In this case, we'll be using the MySQL loader:

SlimeLoader sqlLoader = plugin.getLoader("mysql");

Before actually loading the world, you need a SlimePropertyMap Object. Check the property api documentation for further details.

That's it, you've got everything you need! Now, let's load the world from the data source and generate it:

try {
    // Note that this method should be called asynchronously
    SlimeWorld world = plugin.loadWorld(sqlLoader, "my-world", props);

    // This method must be called synchronously
    plugin.generateWorld(world);
} catch (UnknownWorldException | IOException | CorruptedWorldException | NewerFormatException | WorldInUseException | UnsupportedWorldException ex) {
    /* Exception handling */
}