From 180680f2972496241db7f443e06fefeaea0ff0dc Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:01:26 +0800 Subject: [PATCH] Add method to get MultiverseWorld from a bukkit world. --- .../mvplugins/multiverse/core/world/WorldManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java index c4064263..1d5d1777 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java @@ -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 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.