Package org.bukkit

Class WorldCreator


  • public class WorldCreator
    extends Object
    Represents various types of options that may be used to create a world.
    • Constructor Detail

      • WorldCreator

        public WorldCreator​(@NotNull
                            @NotNull String name)
        Creates an empty WorldCreationOptions for the given world name
        Parameters:
        name - Name of the world that will be created
    • Method Detail

      • name

        @NotNull
        public @NotNull String name()
        Gets the name of the world that is to be loaded or created.
        Returns:
        World name
      • seed

        public long seed()
        Gets the seed that will be used to create this world
        Returns:
        World seed
      • seed

        @NotNull
        public @NotNull WorldCreator seed​(long seed)
        Sets the seed that will be used to create this world
        Parameters:
        seed - World seed
        Returns:
        This object, for chaining
      • environment

        @NotNull
        public World.Environment environment()
        Gets the environment that will be used to create or load the world
        Returns:
        World environment
      • type

        @NotNull
        public @NotNull WorldType type()
        Gets the type of the world that will be created or loaded
        Returns:
        World type
      • generator

        @Nullable
        public @Nullable ChunkGenerator generator()
        Gets the generator that will be used to create or load the world.

        This may be null, in which case the "natural" generator for this environment will be used.

        Returns:
        Chunk generator
      • generator

        @NotNull
        public @NotNull WorldCreator generator​(@Nullable
                                               @Nullable ChunkGenerator generator)
        Sets the generator that will be used to create or load the world.

        This may be null, in which case the "natural" generator for this environment will be used.

        Parameters:
        generator - Chunk generator
        Returns:
        This object, for chaining
      • generator

        @NotNull
        public @NotNull WorldCreator generator​(@Nullable
                                               @Nullable String generator)
        Sets the generator that will be used to create or load the world.

        This may be null, in which case the "natural" generator for this environment will be used.

        If the generator cannot be found for the given name, the natural environment generator will be used instead and a warning will be printed to the console.

        Parameters:
        generator - Name of the generator to use, in "plugin:id" notation
        Returns:
        This object, for chaining
      • generator

        @NotNull
        public @NotNull WorldCreator generator​(@Nullable
                                               @Nullable String generator,
                                               @Nullable
                                               @Nullable CommandSender output)
        Sets the generator that will be used to create or load the world.

        This may be null, in which case the "natural" generator for this environment will be used.

        If the generator cannot be found for the given name, the natural environment generator will be used instead and a warning will be printed to the specified output

        Parameters:
        generator - Name of the generator to use, in "plugin:id" notation
        output - CommandSender that will receive any error messages
        Returns:
        This object, for chaining
      • generatorSettings

        @NotNull
        public @NotNull WorldCreator generatorSettings​(@NotNull
                                                       @NotNull String generatorSettings)
        Sets the generator settings of the world that will be created or loaded.

        Currently only WorldType.FLAT uses these settings, and expects them to be in JSON format with a valid biome defined. An example valid configuration is as follows: {"layers": [{"block": "stone", "height": 1}, {"block": "grass", "height": 1}], "biome":"plains"}

        Parameters:
        generatorSettings - The settings that should be used by the generator
        Returns:
        This object, for chaining
      • generateStructures

        @NotNull
        public @NotNull WorldCreator generateStructures​(boolean generate)
        Sets whether or not worlds created or loaded with this creator will have structures.
        Parameters:
        generate - Whether to generate structures
        Returns:
        This object, for chaining
      • generateStructures

        public boolean generateStructures()
        Gets whether or not structures will be generated in the world.
        Returns:
        True if structures will be generated
      • hardcore

        @NotNull
        public @NotNull WorldCreator hardcore​(boolean hardcore)
        Sets whether the world will be hardcore or not. In a hardcore world the difficulty will be locked to hard.
        Parameters:
        hardcore - Whether the world will be hardcore
        Returns:
        This object, for chaining
      • hardcore

        public boolean hardcore()
        Gets whether the world will be hardcore or not. In a hardcore world the difficulty will be locked to hard.
        Returns:
        hardcore status
      • createWorld

        @Nullable
        public @Nullable World createWorld()
        Creates a world with the specified options.

        If the world already exists, it will be loaded from disk and some options may be ignored.

        Returns:
        Newly created or loaded world
      • getGeneratorForName

        @Nullable
        public static @Nullable ChunkGenerator getGeneratorForName​(@NotNull
                                                                   @NotNull String world,
                                                                   @Nullable
                                                                   @Nullable String name,
                                                                   @Nullable
                                                                   @Nullable CommandSender output)
        Attempts to get the ChunkGenerator with the given name.

        If the generator is not found, null will be returned and a message will be printed to the specified CommandSender explaining why.

        The name must be in the "plugin:id" notation, or optionally just "plugin", where "plugin" is the safe-name of a plugin and "id" is an optional unique identifier for the generator you wish to request from the plugin.

        Parameters:
        world - Name of the world this will be used for
        name - Name of the generator to retrieve
        output - Where to output if errors are present
        Returns:
        Resulting generator, or null