Skip to content

Developer API ​

For plugins that open worlds from templates: minigames resetting an arena, duels opening one world per match, events, build servers. The server owner installs FastWorldLoader; your plugin only compiles against the API.

Dependency ​

The API is free to compile against; the API classes come from the installed FastWorldLoader jar at runtime, so don't shade them.

Not on Maven Central yet

The FastWorldLoader-API artifact will be published to Maven Central soon; the coordinates below are the ones it will have.

kotlin
dependencies {
    compileOnly("io.github.erano01:FastWorldLoader-API:1.0.0")
}
xml
<dependency>
    <groupId>io.github.erano01</groupId>
    <artifactId>FastWorldLoader-API</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

plugin.yml: softdepend: [FastWorldLoader] (or depend if your plugin can't work without it), so FastWorldLoader enables first.

Getting the service ​

java
FastWorlds worlds = null;
if (Bukkit.getPluginManager().isPluginEnabled("FastWorldLoader")) {
    worlds = Bukkit.getServicesManager().load(FastWorlds.class);
}

With softdepend, keep every reference to me.erano.com.fwl.api classes in a class you only load when FastWorldLoader is enabled; on a server without it, loading that class would throw NoClassDefFoundError.

Templates and worlds ​

java
// Once (an admin command, or at setup): a world folder becomes a template.
worlds.importFolder(new File(Bukkit.getWorldContainer(), "maps/castle"), "castle")
      .whenComplete((ok, error) -> { /* runs off the server thread */ });

// Every game (server thread): open, play, close.
World arena = worlds.open("castle", "castle-game-12");
// ...
for (Player player : arena.getPlayers()) {
    player.teleport(lobby);          // close refuses while players are inside
}
worlds.close(arena);                 // changes are thrown away, the folder deleted
MethodThreadNotes
importFolder(folder, template)any, futurethe folder's overworld, else its only dimension
importFolder(folder, template, environment)any, futureone dimension of a folder that has several
open(template, world) / open(template, world, options)serverthrows IllegalArgumentException (no template, bad name), IllegalStateException (name taken, couldn't open, or a template saved by a newer server)
close(world)serverfalse while players are inside or if the server refuses to unload
saveAsTemplate(world, template)server, futurean admin's edit becomes the template; the old one is replaced only once the new one is written
exportTemplate(template, folder)server, futurethe template as a normal world folder; the folder must not exist or be empty
deleteTemplate(template)any, futureworlds open from it keep working
hasTemplate, templates, templateOf(world), openWorlds()any / servertemplateOf is empty for worlds FastWorldLoader didn't open
apiVersion()anythe newest API the installed FastWorldLoader has

Names (templates and worlds): letters, digits, _ - ., at most 64 characters.

Open options ​

java
World end = worlds.open("castle", "castle-end-1", OpenOptions.builder()
        .environment(World.Environment.THE_END)   // open the template as another dimension
        .keepSpawnLoaded(false)                    // default: config keep-spawn-loaded
        .build());

Events ​

EventWhenThread
FastWorldOpenEventa world was opened (after Bukkit's WorldLoadEvent)server
FastWorldCloseEventa world opened by FastWorldLoader is about to close (still loaded)server
TemplateSaveEventa template was imported (Cause.IMPORT) or saved from a world (Cause.SAVE)async
TemplateDeleteEventa template was deletedasync

On a shared (MYSQL) store, TemplateSaveEvent and TemplateDeleteEvent fire on the server that made the change.

Versioning ​

The API follows semantic versioning: 1.x only adds. Methods and events carry @since; apiVersion() returns the newest the installed FastWorldLoader has, so a plugin built against a newer API can check before calling something an older FastWorldLoader doesn't have.

java
if (worlds.apiVersion() >= 2) {
    // a method added in API 2
}

Only FastWorldLoader implements FastWorlds; don't implement it yourself — new methods would break your class.

SurvivalGames is a paid plugin. EranoAPI is open source under the MIT license.