Interface WorldManager


public interface WorldManager
  • Method Details

    • server

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

      Gets a world by a key.
      Parameters:
      key - The key
      Returns:
      The world, if found
    • worldDirectory

      Path worldDirectory(ResourceKey key)
      Gets a directory that is used for the world's data identified by world key. It is not guaranteed the path will exist until the world is formally loaded by the game.
      Parameters:
      key - The world's identifier key
      Returns:
      The directory to be used if it doesn't exist
    • worlds

      Gets all currently loaded worlds.
      Returns:
      The worlds
    • 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
    • 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
    • worldKey

      Optional<ResourceKey> worldKey(UUID uniqueId)
      Gets a key by unique id.
      Parameters:
      uniqueId - The unique id
      Returns:
      The key or Optional.empty() if not found
    • worldsOfType

      Collection<ServerWorld> worldsOfType(WorldType type)
      Retrieves all worlds that are of a particular type.
      Parameters:
      type - The type
      Returns:
      The worlds
    • loadWorld

      Loads a world from a template.

      If a world is already loaded by the key of the template, the world will be returned instead.

      Parameters:
      template - The template
      Returns:
      The world
    • loadWorld

      Loads a world by a key.

      If a world with the given name is already loaded then it is returned instead.

      Parameters:
      key - The key
      Returns:
      The world
    • unloadWorld

      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
    • loadProperties

      Loads an offline properties.

      It is left up to the implementation on what conditions cause a failure of loading properties.

      Parameters:
      key - The key
      Returns:
      The properties
    • saveProperties

      CompletableFuture<Boolean> saveProperties(ServerWorldProperties properties)
      Saves a properties.
      Parameters:
      properties - The properties
      Returns:
      True if successful, false if not
    • 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

      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.