Interface WorldManager


  • public interface WorldManager
    • Method Detail

      • server

        Server server()
        Gets the Server.
        Returns:
        The server
      • worldDirectory

        Optional<Path> worldDirectory​(ResourceKey key)
        Gets a directory that exists for the provided world key.

        It is not required for the implementation to validate that the directory contains a proper world, only that the directory exists.

        Parameters:
        key - The key
        Returns:
        The directory or Optional.empty() if not found
      • defaultWorld

        ServerWorld defaultWorld()
        Gets the default world.

        If the default world isn't loaded, an IllegalStateException will be thrown as this means the manager is not loaded yet.

        It is up to the implementation to define what the default world actually is.

        Returns:
        The default world
      • worldKeys

        List<ResourceKey> worldKeys()
        Gets the keys of both online and offline worlds.

        It is up to the implementation to determine how offline keys are provided to the developer.

        Returns:
        The keys
      • templateKeys

        List<ResourceKey> templateKeys()
        Gets the keys of templates.

        It is up to the implementation to determine how template keys are provided to the developer.

        Returns:
        The keys
      • offlineWorldKeys

        default List<ResourceKey> offlineWorldKeys()
        Gets the keys of offline worlds.

        It is up to the implementation to determine how offline keys are provided to the developer.

        Returns:
        The keys
      • worldExists

        boolean worldExists​(ResourceKey key)
        Gets if a key exists as an actual world, offline or online.
        Parameters:
        key - The key
        Returns:
        True if existed, false if not
      • unloadWorld

        CompletableFuture<Boolean> unloadWorld​(ResourceKey key)
        Unloads a world by a key.

        The default Minecraft world cannot be unloaded. Additional conditions for how and when a world may be unloaded are left up to the implementation to define.

        Parameters:
        key - The key to unload
        Returns:
        Whether the operation was successful
      • unloadWorld

        CompletableFuture<Boolean> unloadWorld​(ServerWorld world)
        Unloads a world.

        The default Minecraft world cannot be unloaded. Additional conditions for how and when a world may be unloaded are left up to the implementation to define.

        Parameters:
        world - The world to unload
        Returns:
        Whether the operation was successful
      • templateExists

        boolean templateExists​(ResourceKey key)
        Gets if a key exists as a template.
        Parameters:
        key - The key
        Returns:
        True if it exists, false if not
      • saveTemplate

        CompletableFuture<Boolean> saveTemplate​(WorldTemplate template)
        Saves a template.

        It is left up to the implementation on how exactly templates are saved, if at all.

        Parameters:
        template - The template
        Returns:
        Whether the operation was successful
      • copyWorld

        CompletableFuture<Boolean> copyWorld​(ResourceKey key,
                                             ResourceKey copyKey)
        Copies world data under the provided key to a provided key.

        If the world is loaded, the following will occur:

        • World is saved
        • World saving is disabled
        • World is copied
        • World saving is enabled

        It is left up to the implementation on exactly what is copied.

        Parameters:
        key - The key
        copyKey - The copied key for the new properties
        Returns:
        The copied properties
      • moveWorld

        CompletableFuture<Boolean> moveWorld​(ResourceKey key,
                                             ResourceKey moveKey)
        Moves world data under the provided key to another key.

        If the world is loaded, the following will occur:

        • World is saved
        • World is unloaded
        • World is moved

        The default Minecraft world cannot be moved. Additionally, it is left up to the implementation on exactly what is moved.

        Parameters:
        key - The key
        moveKey - The move key
        Returns:
        True if the move was successful
      • deleteWorld

        CompletableFuture<Boolean> deleteWorld​(ResourceKey key)
        Deletes world data under the provided key.

        If the world is loaded, the following will occur:

        • World is unloaded
        • World is deleted

        The default Minecraft world cannot be deleted. Additionally, it is left up to the implementation on exactly what is deleted.

        Parameters:
        key - The key
        Returns:
        True if the deletion was successful.