Class WorldManager

  • All Implemented Interfaces:
    MVWorldManager

    public class WorldManager
    extends java.lang.Object
    implements MVWorldManager
    Public facing API to add/remove Multiverse worlds.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean addWorld​(java.lang.String name, org.bukkit.World.Environment env, java.lang.String seedString, org.bukkit.WorldType type, java.lang.Boolean generateStructures, java.lang.String generator)
      Add a new World to the Multiverse Setup.
      boolean addWorld​(java.lang.String name, org.bukkit.World.Environment env, java.lang.String seedString, org.bukkit.WorldType type, java.lang.Boolean generateStructures, java.lang.String generator, boolean useSpawnAdjust)
      Add a new World to the Multiverse Setup.
      boolean cloneWorld​(java.lang.String oldName, java.lang.String newName)
      Make a copy of a world.
      boolean cloneWorld​(java.lang.String oldName, java.lang.String newName, java.lang.String generator)
      Deprecated.
      boolean deleteWorld​(java.lang.String name)
      Remove the world from the Multiverse list, from the config and deletes the folder.
      boolean deleteWorld​(java.lang.String name, boolean removeFromConfig)
      Remove the world from the Multiverse list, from the config if wanted, and deletes the folder.
      boolean deleteWorld​(java.lang.String name, boolean removeFromConfig, boolean deleteWorldFolder)
      org.bukkit.generator.ChunkGenerator getChunkGenerator​(java.lang.String generator, java.lang.String generatorID, java.lang.String worldName)
      Test if a given chunk generator is valid.
      org.bukkit.configuration.file.FileConfiguration getConfigWorlds()
      Gets the FileConfiguration that this WorldManager is using.
      void getDefaultWorldGenerators()
      This method populates an internal list and needs to be called after multiverse initialization.
      MultiverseWorld getFirstSpawnWorld()
      Gets the world players should spawn in first.
      MultiverseWorld getMVWorld​(java.lang.String name)
      Returns a MultiverseWorld if it exists, and null if it does not.
      MultiverseWorld getMVWorld​(java.lang.String name, boolean checkAliases)
      Returns a MultiverseWorld if the world with name given exists, and null if it does not.
      MultiverseWorld getMVWorld​(org.bukkit.World world)
      Returns a MultiverseWorld if it exists, and null if it does not.
      java.util.Collection<MultiverseWorld> getMVWorlds()
      Returns a list of all the worlds Multiverse knows about.
      java.util.Collection<java.lang.String> getPotentialWorlds()
      Get all the possible worlds that Multiverse has detected to be importable.
      MultiverseWorld getSpawnWorld()
      Gets the world players will spawn in on first join.
      WorldPurger getTheWorldPurger()
      Gets the WorldPurger.
      java.util.List<java.lang.String> getUnloadedWorlds()
      Gets the list of worlds in the config, but unloaded.
      PurgeWorlds getWorldPurger()
      Deprecated.
      This is deprecated!
      boolean hasUnloadedWorld​(java.lang.String name, boolean includeLoaded)
      Checks whether Multiverse knows about a provided unloaded world.
      boolean isKeepingSpawnInMemory​(org.bukkit.World world)  
      boolean isMVWorld​(java.lang.String name)
      Checks to see if the given name is a valid MultiverseWorld Searches based on world name AND alias.
      boolean isMVWorld​(java.lang.String name, boolean checkAliases)
      Checks to see if the given name is a valid MultiverseWorld.
      boolean isMVWorld​(org.bukkit.World world)
      Checks to see if the given world is a valid MultiverseWorld.
      void loadDefaultWorlds()
      Loads the Worlds & Settings for any worlds that bukkit loaded before us.
      boolean loadWorld​(java.lang.String name)
      Loads the world.
      org.bukkit.configuration.file.FileConfiguration loadWorldConfig​(java.io.File file)
      Load the config from a file.
      void loadWorlds​(boolean forceLoad)
      Load the Worlds & Settings from the configuration file.
      boolean regenWorld​(java.lang.String name, boolean useNewSeed, boolean randomSeed, java.lang.String seed)
      Regenerates a world.
      boolean regenWorld​(java.lang.String name, boolean useNewSeed, boolean randomSeed, java.lang.String seed, boolean keepGameRules)
      Regenerates a world.
      void removePlayersFromWorld​(java.lang.String name)
      Removes all players from the specified world.
      boolean removeWorldFromConfig​(java.lang.String name)
      Remove the world from the Multiverse list and from the config.
      boolean saveWorldsConfig()
      Saves the world config to disk.
      void setFirstSpawnWorld​(java.lang.String world)
      Sets the initial spawn world for new players.
      boolean unloadWorld​(java.lang.String name)
      Unload a world from Multiverse.
      boolean unloadWorld​(java.lang.String name, boolean unloadBukkit)
      Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getDefaultWorldGenerators

        public void getDefaultWorldGenerators()
        This method populates an internal list and needs to be called after multiverse initialization.
        Specified by:
        getDefaultWorldGenerators in interface MVWorldManager
      • cloneWorld

        @Deprecated
        public boolean cloneWorld​(java.lang.String oldName,
                                  java.lang.String newName,
                                  java.lang.String generator)
        Deprecated.
        Make a copy of a world.
        Specified by:
        cloneWorld in interface MVWorldManager
        Parameters:
        oldName - Name of world to be copied
        newName - Name of world to be created
        generator - The Custom generator plugin to use. Ignored.
        Returns:
        True if the world is copied successfully, false if not.
      • cloneWorld

        public boolean cloneWorld​(java.lang.String oldName,
                                  java.lang.String newName)
        Make a copy of a world.
        Specified by:
        cloneWorld in interface MVWorldManager
        Parameters:
        oldName - Name of world to be copied
        newName - Name of world to be created
        Returns:
        True if the world is copied successfully, false if not.
      • addWorld

        public boolean addWorld​(java.lang.String name,
                                org.bukkit.World.Environment env,
                                java.lang.String seedString,
                                org.bukkit.WorldType type,
                                java.lang.Boolean generateStructures,
                                java.lang.String generator)
        Add a new World to the Multiverse Setup.
        Specified by:
        addWorld in interface MVWorldManager
        Parameters:
        name - World Name
        env - Environment Type
        seedString - The seed in the form of a string. If the seed is a Long, it will be interpreted as such.
        type - The Type of the world to be made.
        generateStructures - If true, this world will get NPC villages.
        generator - The Custom generator plugin to use.
        Returns:
        True if the world is added, false if not.
      • addWorld

        public boolean addWorld​(java.lang.String name,
                                org.bukkit.World.Environment env,
                                java.lang.String seedString,
                                org.bukkit.WorldType type,
                                java.lang.Boolean generateStructures,
                                java.lang.String generator,
                                boolean useSpawnAdjust)
        Add a new World to the Multiverse Setup.
        Specified by:
        addWorld in interface MVWorldManager
        Parameters:
        name - World Name
        env - Environment Type
        seedString - The seed in the form of a string. If the seed is a Long, it will be interpreted as such.
        type - The Type of the world to be made.
        generateStructures - If true, this world will get NPC villages.
        generator - The Custom generator plugin to use.
        useSpawnAdjust - If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
        Returns:
        True if the world is added, false if not.
      • getChunkGenerator

        public org.bukkit.generator.ChunkGenerator getChunkGenerator​(java.lang.String generator,
                                                                     java.lang.String generatorID,
                                                                     java.lang.String worldName)
        Test if a given chunk generator is valid.
        Specified by:
        getChunkGenerator in interface MVWorldManager
        Parameters:
        generator - The generator name.
        generatorID - The generator id.
        worldName - The worldName to use as the default.
        Returns:
        A ChunkGenerator or null
      • removeWorldFromConfig

        public boolean removeWorldFromConfig​(java.lang.String name)
        Remove the world from the Multiverse list and from the config.
        Specified by:
        removeWorldFromConfig in interface MVWorldManager
        Parameters:
        name - The name of the world to remove
        Returns:
        True if success, false if failure.
      • setFirstSpawnWorld

        public void setFirstSpawnWorld​(java.lang.String world)
        Sets the initial spawn world for new players.
        Specified by:
        setFirstSpawnWorld in interface MVWorldManager
        Parameters:
        world - The World new players should spawn in.
      • unloadWorld

        public boolean unloadWorld​(java.lang.String name)
        Unload a world from Multiverse.
        Specified by:
        unloadWorld in interface MVWorldManager
        Parameters:
        name - Name of the world to unload
        Returns:
        True if the world was unloaded, false if not.
      • unloadWorld

        public boolean unloadWorld​(java.lang.String name,
                                   boolean unloadBukkit)
        Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
        Specified by:
        unloadWorld in interface MVWorldManager
        Parameters:
        name - Name of the world to unload
        unloadBukkit - True if Bukkit world should be unloaded
        Returns:
        True if the world was unloaded, false if not.
      • loadWorld

        public boolean loadWorld​(java.lang.String name)
        Loads the world. Only use this if the world has been unloaded with MVWorldManager.unloadWorld(String).
        Specified by:
        loadWorld in interface MVWorldManager
        Parameters:
        name - The name of the world to load
        Returns:
        True if success, false if failure.
      • deleteWorld

        public boolean deleteWorld​(java.lang.String name,
                                   boolean removeFromConfig,
                                   boolean deleteWorldFolder)
        Specified by:
        deleteWorld in interface MVWorldManager
        Parameters:
        name - The name of the world to remove
        removeFromConfig - If true(default), we'll remove the entries from the config. If false, they'll stay and the world may come back.
        deleteWorldFolder - If true the world folder will be completely deleted. If false only the contents of the world folder will be deleted
        Returns:
        True if success, false if failure.
      • deleteWorld

        public boolean deleteWorld​(java.lang.String name,
                                   boolean removeFromConfig)
        Remove the world from the Multiverse list, from the config if wanted, and deletes the folder.
        Specified by:
        deleteWorld in interface MVWorldManager
        Parameters:
        name - The name of the world to remove
        removeFromConfig - If true(default), we'll remove the entries from the config. If false, they'll stay and the world may come back.
        Returns:
        True if success, false if failure.
      • deleteWorld

        public boolean deleteWorld​(java.lang.String name)
        Remove the world from the Multiverse list, from the config and deletes the folder.
        Specified by:
        deleteWorld in interface MVWorldManager
        Parameters:
        name - The name of the world to remove
        Returns:
        True if success, false if failure.
      • removePlayersFromWorld

        public void removePlayersFromWorld​(java.lang.String name)
        Removes all players from the specified world.
        Specified by:
        removePlayersFromWorld in interface MVWorldManager
        Parameters:
        name - World to remove players from.
      • getMVWorld

        public MultiverseWorld getMVWorld​(java.lang.String name,
                                          boolean checkAliases)
        Returns a MultiverseWorld if the world with name given exists, and null if it does not. This will search optionally for alias names.
        Specified by:
        getMVWorld in interface MVWorldManager
        Parameters:
        name - The name or optionally the alias of the world to get.
        checkAliases - Indicates whether to check for world alias name.
        Returns:
        A MultiverseWorld or null.
      • isMVWorld

        public boolean isMVWorld​(java.lang.String name)
        Checks to see if the given name is a valid MultiverseWorld Searches based on world name AND alias.
        Specified by:
        isMVWorld in interface MVWorldManager
        Parameters:
        name - The name or alias of the world to check.
        Returns:
        True if the world exists, false if not.
      • isMVWorld

        public boolean isMVWorld​(java.lang.String name,
                                 boolean checkAliases)
        Checks to see if the given name is a valid MultiverseWorld. Optionally searches by alias is specified.
        Specified by:
        isMVWorld in interface MVWorldManager
        Parameters:
        name - The name or alias of the world to check.
        checkAliases - Indicates whether to check for world alias name.
        Returns:
        True if the world exists, false if not.
      • isMVWorld

        public boolean isMVWorld​(org.bukkit.World world)
        Checks to see if the given world is a valid MultiverseWorld.
        Specified by:
        isMVWorld in interface MVWorldManager
        Parameters:
        world - The Bukkit world to check.
        Returns:
        True if the world has been loaded into MV2, false if not.
      • loadDefaultWorlds

        public void loadDefaultWorlds()
        Loads the Worlds & Settings for any worlds that bukkit loaded before us.

        This way people will _always_ have some worlds in the list.

        Specified by:
        loadDefaultWorlds in interface MVWorldManager
      • loadWorlds

        public void loadWorlds​(boolean forceLoad)
        Load the Worlds & Settings from the configuration file.
        Specified by:
        loadWorlds in interface MVWorldManager
        Parameters:
        forceLoad - If set to true, this will perform a total reset and not just load new worlds.
      • loadWorldConfig

        public org.bukkit.configuration.file.FileConfiguration loadWorldConfig​(java.io.File file)
        Load the config from a file.
        Specified by:
        loadWorldConfig in interface MVWorldManager
        Parameters:
        file - The file to load.
        Returns:
        A loaded configuration.
      • saveWorldsConfig

        public boolean saveWorldsConfig()
        Saves the world config to disk.
        Specified by:
        saveWorldsConfig in interface MVWorldManager
        Returns:
        True if success, false if fail.
      • getSpawnWorld

        public MultiverseWorld getSpawnWorld()
        Gets the world players will spawn in on first join. Currently this always returns worlds.get(0) from Bukkit.
        Specified by:
        getSpawnWorld in interface MVWorldManager
        Returns:
        A Multiverse world that players will spawn in or null if no MV world has been set.
      • getUnloadedWorlds

        public java.util.List<java.lang.String> getUnloadedWorlds()
        Gets the list of worlds in the config, but unloaded.
        Specified by:
        getUnloadedWorlds in interface MVWorldManager
        Returns:
        A List of worlds as strings.
      • regenWorld

        public boolean regenWorld​(java.lang.String name,
                                  boolean useNewSeed,
                                  boolean randomSeed,
                                  java.lang.String seed)
        Regenerates a world.
        Specified by:
        regenWorld in interface MVWorldManager
        Parameters:
        name - Name of the world to regenerate
        useNewSeed - If a new seed should be used
        randomSeed - If the new seed should be random
        seed - The seed of the world.
        Returns:
        True if success, false if fail.
      • regenWorld

        public boolean regenWorld​(java.lang.String name,
                                  boolean useNewSeed,
                                  boolean randomSeed,
                                  java.lang.String seed,
                                  boolean keepGameRules)
        Regenerates a world.
        Specified by:
        regenWorld in interface MVWorldManager
        Parameters:
        name - Name of the world to regenerate
        useNewSeed - If a new seed should be used
        randomSeed - If the new seed should be random
        seed - The seed of the world.
        keepGameRules - If GameRules should be kept on world regen.
        Returns:
        True if success, false if fail.
      • getConfigWorlds

        public org.bukkit.configuration.file.FileConfiguration getConfigWorlds()
        Gets the FileConfiguration that this WorldManager is using.
        Returns:
        The FileConfiguration that this WorldManager is using.
      • hasUnloadedWorld

        public boolean hasUnloadedWorld​(java.lang.String name,
                                        boolean includeLoaded)
        Checks whether Multiverse knows about a provided unloaded world. This method will check the parameter against the alias mappings.
        Specified by:
        hasUnloadedWorld in interface MVWorldManager
        Parameters:
        name - The name of the unloaded world
        includeLoaded - The value to return if the world is loaded
        Returns:
        True if the world exists and is unloaded. False if the world does not exist. includeLoaded if the world exists and is loaded.
      • getPotentialWorlds

        public java.util.Collection<java.lang.String> getPotentialWorlds()
        Get all the possible worlds that Multiverse has detected to be importable.
        Specified by:
        getPotentialWorlds in interface MVWorldManager
        Returns:
        A collection of world names that are deemed importable.