Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.WorldCreator Class Reference

Public Member Functions

 WorldCreator (String name)
 
WorldCreator copy (World world)
 
WorldCreator copy (WorldCreator creator)
 
String name ()
 
long seed ()
 
WorldCreator seed (long seed)
 
World.Environment environment ()
 
WorldCreator environment (World.Environment env)
 
WorldType type ()
 
WorldCreator type (WorldType type)
 
ChunkGenerator generator ()
 
WorldCreator generator (ChunkGenerator generator)
 
WorldCreator generator (String generator)
 
WorldCreator generator (String generator, CommandSender output)
 
WorldCreator generateStructures (boolean generate)
 
boolean generateStructures ()
 
World createWorld ()
 

Static Public Member Functions

static WorldCreator name (String name)
 
static ChunkGenerator getGeneratorForName (String world, String name, CommandSender output)
 

Detailed Description

Represents various types of options that may be used to create a world.

Definition at line 11 of file WorldCreator.java.

Constructor & Destructor Documentation

org.bukkit.WorldCreator.WorldCreator ( String  name)

Creates an empty WorldCreationOptions for the given world name

Parameters
nameName of the world that will be created

Definition at line 24 of file WorldCreator.java.

References org.bukkit.WorldCreator.name().

Referenced by org.bukkit.WorldCreator.name().

24  {
25  if (name == null) {
26  throw new IllegalArgumentException("World name cannot be null");
27  }
28 
29  this.name = name;
30  this.seed = (new Random()).nextLong();
31  }

Member Function Documentation

WorldCreator org.bukkit.WorldCreator.copy ( World  world)

Copies the options from the specified world

Parameters
worldWorld to copy options from
Returns
This object, for chaining

Definition at line 39 of file WorldCreator.java.

References org.bukkit.WorldCreator.environment(), org.bukkit.World.getEnvironment(), org.bukkit.World.getGenerator(), and org.bukkit.World.getSeed().

39  {
40  if (world == null) {
41  throw new IllegalArgumentException("World cannot be null");
42  }
43 
44  seed = world.getSeed();
45  environment = world.getEnvironment();
46  generator = world.getGenerator();
47 
48  return this;
49  }
ChunkGenerator generator()
World.Environment environment()
Environment getEnvironment()
WorldCreator org.bukkit.WorldCreator.copy ( WorldCreator  creator)

Copies the options from the specified WorldCreator

Parameters
creatorWorld creator to copy options from
Returns
This object, for chaining

Definition at line 57 of file WorldCreator.java.

References org.bukkit.WorldCreator.environment().

57  {
58  if (creator == null) {
59  throw new IllegalArgumentException("Creator cannot be null");
60  }
61 
62  seed = creator.seed();
63  environment = creator.environment();
64  generator = creator.generator();
65 
66  return this;
67  }
ChunkGenerator generator()
World.Environment environment()
World org.bukkit.WorldCreator.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

Definition at line 238 of file WorldCreator.java.

References org.bukkit.Bukkit.createWorld().

238  {
239  return Bukkit.createWorld(this);
240  }
World.Environment org.bukkit.WorldCreator.environment ( )

Gets the environment that will be used to create or load the world

Returns
World environment

Definition at line 104 of file WorldCreator.java.

Referenced by org.bukkit.WorldCreator.copy(), and org.bukkit.WorldCreator.environment().

104  {
105  return environment;
106  }
World.Environment environment()
WorldCreator org.bukkit.WorldCreator.environment ( World.Environment  env)

Sets the environment that will be used to create or load the world

Parameters
envWorld environment
Returns
This object, for chaining

Definition at line 114 of file WorldCreator.java.

References org.bukkit.WorldCreator.environment().

114  {
115  this.environment = env;
116 
117  return this;
118  }
World.Environment environment()
WorldCreator org.bukkit.WorldCreator.generateStructures ( boolean  generate)

Sets whether or not worlds created or loaded with this creator will have structures.

Parameters
generateWhether to generate structures
Returns
This object, for chaining

Definition at line 215 of file WorldCreator.java.

215  {
216  this.generateStructures = generate;
217 
218  return this;
219  }
boolean org.bukkit.WorldCreator.generateStructures ( )

Gets whether or not structures will be generated in the world.

Returns
True if structures will be generated

Definition at line 226 of file WorldCreator.java.

226  {
227  return generateStructures;
228  }
ChunkGenerator org.bukkit.WorldCreator.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

Definition at line 149 of file WorldCreator.java.

Referenced by org.bukkit.WorldCreator.generator().

149  {
150  return generator;
151  }
ChunkGenerator generator()
WorldCreator org.bukkit.WorldCreator.generator ( 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
generatorChunk generator
Returns
This object, for chaining

Definition at line 162 of file WorldCreator.java.

References org.bukkit.WorldCreator.generator().

162  {
163  this.generator = generator;
164 
165  return this;
166  }
ChunkGenerator generator()
WorldCreator org.bukkit.WorldCreator.generator ( 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
generatorName of the generator to use, in "plugin:id" notation
Returns
This object, for chaining

Definition at line 181 of file WorldCreator.java.

References org.bukkit.Bukkit.getConsoleSender(), and org.bukkit.WorldCreator.getGeneratorForName().

181  {
182  this.generator = getGeneratorForName(name, generator, Bukkit.getConsoleSender());
183 
184  return this;
185  }
static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output)
ChunkGenerator generator()
WorldCreator org.bukkit.WorldCreator.generator ( String  generator,
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
generatorName of the generator to use, in "plugin:id" notation
outputCommandSender that will receive any error messages
Returns
This object, for chaining

Definition at line 202 of file WorldCreator.java.

References org.bukkit.WorldCreator.getGeneratorForName().

202  {
203  this.generator = getGeneratorForName(name, generator, output);
204 
205  return this;
206  }
static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output)
ChunkGenerator generator()
static ChunkGenerator org.bukkit.WorldCreator.getGeneratorForName ( String  world,
String  name,
CommandSender  output 
)
static

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
worldName of the world this will be used for
nameName of the generator to retrieve
outputWhere to output if errors are present
Returns
Resulting generator, or null

Definition at line 268 of file WorldCreator.java.

References org.bukkit.Bukkit.getConsoleSender(), org.bukkit.plugin.Plugin.getDefaultWorldGenerator(), org.bukkit.plugin.Plugin.getDescription(), org.bukkit.plugin.PluginDescriptionFile.getFullName(), org.bukkit.plugin.PluginManager.getPlugin(), org.bukkit.Bukkit.getPluginManager(), org.bukkit.plugin.Plugin.isEnabled(), and org.bukkit.command.CommandSender.sendMessage().

Referenced by org.bukkit.WorldCreator.generator().

268  {
269  ChunkGenerator result = null;
270 
271  if (world == null) {
272  throw new IllegalArgumentException("World name must be specified");
273  }
274 
275  if (output == null) {
276  output = Bukkit.getConsoleSender();
277  }
278 
279  if (name != null) {
280  String[] split = name.split(":", 2);
281  String id = (split.length > 1) ? split[1] : null;
282  Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]);
283 
284  if (plugin == null) {
285  output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + split[0] + "' does not exist");
286  } else if (!plugin.isEnabled()) {
287  output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled");
288  } else {
289  result = plugin.getDefaultWorldGenerator(world, id);
290  }
291  }
292 
293  return result;
294  }
String org.bukkit.WorldCreator.name ( )

Gets the name of the world that is to be loaded or created.

Returns
World name

Definition at line 74 of file WorldCreator.java.

Referenced by org.bukkit.WorldCreator.WorldCreator().

74  {
75  return name;
76  }
static WorldCreator org.bukkit.WorldCreator.name ( String  name)
static

Creates a new WorldCreator for the given world name

Parameters
nameName of the world to load or create
Returns
Resulting WorldCreator

Definition at line 248 of file WorldCreator.java.

References org.bukkit.WorldCreator.WorldCreator().

248  {
249  return new WorldCreator(name);
250  }
long org.bukkit.WorldCreator.seed ( )

Gets the seed that will be used to create this world

Returns
World seed

Definition at line 83 of file WorldCreator.java.

Referenced by org.bukkit.WorldCreator.seed().

83  {
84  return seed;
85  }
WorldCreator org.bukkit.WorldCreator.seed ( long  seed)

Sets the seed that will be used to create this world

Parameters
seedWorld seed
Returns
This object, for chaining

Definition at line 93 of file WorldCreator.java.

References org.bukkit.WorldCreator.seed().

93  {
94  this.seed = seed;
95 
96  return this;
97  }
WorldType org.bukkit.WorldCreator.type ( )

Gets the type of the world that will be created or loaded

Returns
World type

Definition at line 125 of file WorldCreator.java.

Referenced by org.bukkit.WorldCreator.type().

125  {
126  return type;
127  }
WorldCreator org.bukkit.WorldCreator.type ( WorldType  type)

Sets the type of the world that will be created or loaded

Parameters
typeWorld type
Returns
This object, for chaining

Definition at line 135 of file WorldCreator.java.

References org.bukkit.WorldCreator.type().

135  {
136  this.type = type;
137 
138  return this;
139  }

The documentation for this class was generated from the following file: