Add method to get MultiverseWorld from a bukkit world.

This commit is contained in:
Ben Woo 2023-09-20 12:01:26 +08:00
parent db0d5da5ce
commit 180680f297
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
1 changed files with 11 additions and 0 deletions

View File

@ -737,6 +737,17 @@ public class WorldManager {
return !isLoadedWorld(worldName) && isWorld(worldName);
}
/**
* Get a world that may or may not be loaded. It will an {@link LoadedMultiverseWorld} if the world is loaded,
* otherwise returns an {@link MultiverseWorld} instance.
*
* @param world The bukkit world to get.
* @return The world if it exists.
*/
public Option<MultiverseWorld> getWorld(@Nullable World world) {
return Option.of(world).flatMap(this::getWorld);
}
/**
* Get a world that may or may not be loaded. It will an {@link LoadedMultiverseWorld} if the world is loaded,
* otherwise returns an {@link MultiverseWorld} instance.