Class WorldManager
- java.lang.Object
-
- com.onarandombox.MultiverseCore.utils.WorldManager
-
- All Implemented Interfaces:
MVWorldManager
public class WorldManager extends java.lang.Object implements MVWorldManager
Public facing API to add/remove Multiverse worlds.
-
-
Constructor Summary
Constructors Constructor Description WorldManager(MultiverseCore core)
-
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.UsecloneWorld(String, String)
instead.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 theFileConfiguration
that thisWorldManager
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 aMultiverseWorld
if it exists, and null if it does not.MultiverseWorld
getMVWorld(java.lang.String name, boolean checkAliases)
Returns aMultiverseWorld
if the world with name given exists, and null if it does not.MultiverseWorld
getMVWorld(org.bukkit.World world)
Returns aMultiverseWorld
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 theWorldPurger
.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 validMultiverseWorld
Searches based on world name AND alias.boolean
isMVWorld(java.lang.String name, boolean checkAliases)
Checks to see if the given name is a validMultiverseWorld
.boolean
isMVWorld(org.bukkit.World world)
Checks to see if the given world is a validMultiverseWorld
.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.
-
-
-
Constructor Detail
-
WorldManager
public WorldManager(MultiverseCore core)
-
-
Method Detail
-
getDefaultWorldGenerators
public void getDefaultWorldGenerators()
This method populates an internal list and needs to be called after multiverse initialization.- Specified by:
getDefaultWorldGenerators
in interfaceMVWorldManager
-
cloneWorld
@Deprecated public boolean cloneWorld(java.lang.String oldName, java.lang.String newName, java.lang.String generator)
Deprecated.UsecloneWorld(String, String)
instead.Make a copy of a world.- Specified by:
cloneWorld
in interfaceMVWorldManager
- Parameters:
oldName
- Name of world to be copiednewName
- Name of world to be createdgenerator
- 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 interfaceMVWorldManager
- Parameters:
oldName
- Name of world to be copiednewName
- 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 interfaceMVWorldManager
- Parameters:
name
- World Nameenv
- Environment TypeseedString
- 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 interfaceMVWorldManager
- Parameters:
name
- World Nameenv
- Environment TypeseedString
- 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 interfaceMVWorldManager
- 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 interfaceMVWorldManager
- 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 interfaceMVWorldManager
- Parameters:
world
- The World new players should spawn in.
-
getFirstSpawnWorld
public MultiverseWorld getFirstSpawnWorld()
Gets the world players should spawn in first.- Specified by:
getFirstSpawnWorld
in interfaceMVWorldManager
- Returns:
- The
MultiverseWorld
new players should spawn in.
-
unloadWorld
public boolean unloadWorld(java.lang.String name)
Unload a world from Multiverse.- Specified by:
unloadWorld
in interfaceMVWorldManager
- 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 interfaceMVWorldManager
- Parameters:
name
- Name of the world to unloadunloadBukkit
- 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 withMVWorldManager.unloadWorld(String)
.- Specified by:
loadWorld
in interfaceMVWorldManager
- 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 interfaceMVWorldManager
- Parameters:
name
- The name of the world to removeremoveFromConfig
- 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 interfaceMVWorldManager
- Parameters:
name
- The name of the world to removeremoveFromConfig
- 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 interfaceMVWorldManager
- 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 interfaceMVWorldManager
- Parameters:
name
- World to remove players from.
-
getMVWorlds
public java.util.Collection<MultiverseWorld> getMVWorlds()
Returns a list of all the worlds Multiverse knows about.- Specified by:
getMVWorlds
in interfaceMVWorldManager
- Returns:
- A list of
MultiverseWorld
.
-
getMVWorld
public MultiverseWorld getMVWorld(java.lang.String name)
Returns aMultiverseWorld
if it exists, and null if it does not. This will search name AND alias.- Specified by:
getMVWorld
in interfaceMVWorldManager
- Parameters:
name
- The name or alias of the world to get.- Returns:
- A
MultiverseWorld
or null.
-
getMVWorld
public MultiverseWorld getMVWorld(java.lang.String name, boolean checkAliases)
Returns aMultiverseWorld
if the world with name given exists, and null if it does not. This will search optionally for alias names.- Specified by:
getMVWorld
in interfaceMVWorldManager
- 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.
-
getMVWorld
public MultiverseWorld getMVWorld(org.bukkit.World world)
Returns aMultiverseWorld
if it exists, and null if it does not.- Specified by:
getMVWorld
in interfaceMVWorldManager
- Parameters:
world
- The Bukkit world to check.- Returns:
- A
MultiverseWorld
or null.
-
isMVWorld
public boolean isMVWorld(java.lang.String name)
Checks to see if the given name is a validMultiverseWorld
Searches based on world name AND alias.- Specified by:
isMVWorld
in interfaceMVWorldManager
- 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 validMultiverseWorld
. Optionally searches by alias is specified.- Specified by:
isMVWorld
in interfaceMVWorldManager
- 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 validMultiverseWorld
.- Specified by:
isMVWorld
in interfaceMVWorldManager
- 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 interfaceMVWorldManager
-
loadWorlds
public void loadWorlds(boolean forceLoad)
Load the Worlds & Settings from the configuration file.- Specified by:
loadWorlds
in interfaceMVWorldManager
- Parameters:
forceLoad
- If set to true, this will perform a total reset and not just load new worlds.
-
getWorldPurger
@Deprecated public PurgeWorlds getWorldPurger()
Deprecated.This is deprecated!Return the World Purger.- Specified by:
getWorldPurger
in interfaceMVWorldManager
- Returns:
- A valid
PurgeWorlds
.
-
getTheWorldPurger
public WorldPurger getTheWorldPurger()
Gets theWorldPurger
.TODO: Remove
MVWorldManager.getWorldPurger()
and replace it with this method.- Specified by:
getTheWorldPurger
in interfaceMVWorldManager
- Returns:
- The
WorldPurger
thisMVWorldManager
is using. - See Also:
WorldPurger
,SimpleWorldPurger
-
isKeepingSpawnInMemory
public boolean isKeepingSpawnInMemory(org.bukkit.World world)
- Specified by:
isKeepingSpawnInMemory
in interfaceMVWorldManager
-
loadWorldConfig
public org.bukkit.configuration.file.FileConfiguration loadWorldConfig(java.io.File file)
Load the config from a file.- Specified by:
loadWorldConfig
in interfaceMVWorldManager
- Parameters:
file
- The file to load.- Returns:
- A loaded configuration.
-
saveWorldsConfig
public boolean saveWorldsConfig()
Saves the world config to disk.- Specified by:
saveWorldsConfig
in interfaceMVWorldManager
- 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 interfaceMVWorldManager
- 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 interfaceMVWorldManager
- 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 interfaceMVWorldManager
- Parameters:
name
- Name of the world to regenerateuseNewSeed
- If a new seed should be usedrandomSeed
- If the new seed should be randomseed
- 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 interfaceMVWorldManager
- Parameters:
name
- Name of the world to regenerateuseNewSeed
- If a new seed should be usedrandomSeed
- If the new seed should be randomseed
- 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 theFileConfiguration
that thisWorldManager
is using.- Returns:
- The
FileConfiguration
that thisWorldManager
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 interfaceMVWorldManager
- Parameters:
name
- The name of the unloaded worldincludeLoaded
- 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 interfaceMVWorldManager
- Returns:
- A collection of world names that are deemed importable.
-
-