# 2. Create worlds (Builder)

<span style="white-space: pre-wrap;">In GWorld v2, new worlds are created using the </span>**builder pattern**<span style="white-space: pre-wrap;">. This separates the </span>**configuration**<span style="white-space: pre-wrap;"> (registration) from the </span>**generation**<span style="white-space: pre-wrap;"> (load).</span>

# Step 1: The Builder (Registration)

<span style="white-space: pre-wrap;">With the </span>`<span class="editor-theme-code">WorldCreationBuilder </span>`<span style="white-space: pre-wrap;">you define all the properties of the world. Calling </span>`<span class="editor-theme-code">.build()</span>`<span style="white-space: pre-wrap;"> registers the world in the database, but does not yet physically create it.</span>

```java
import de.gilljan.gworld.api.IManageableWorld;
import de.gilljan.gworld.enums.WorldTypeMapping;

// Start the builder
IManageableWorld newWorld = worldManager.createBuilder("MeineEventWelt")
    .worldType(WorldTypeMapping.NORMAL) // Environent: Normal, Nether, End, Large Biomes, Amplified, Flat
    .generator("PlotSquared")           // Optional: Custom Generator Name
    .seed(987654321L)                   // Optional: Set seed
    .build();                           // -> Saves the world to Config/DB
```

<p class="callout info">**Note:**<span style="white-space: pre-wrap;"> The </span>`<span class="editor-theme-code">.build()</span>`<span style="white-space: pre-wrap;"> method internally calls </span>`<span class="editor-theme-code">addWorldFromBuilder</span>`. The world is then known (`<span class="editor-theme-code">registered</span>`<span style="white-space: pre-wrap;">), but still </span>`<span class="editor-theme-code">unloaded</span>`.</p>

## Step 2: Load (generation)

```java
// Creates the bukkit world and loads chunks
boolean success = newWorld.createMap(); 

if (success) {
  getLogger().info("World is ready!");
}
```

<p class="callout success"><span style="white-space: pre-wrap;">The same applies to imports. Use the folder name of the world and use the </span>`<span class="editor-theme-code">importMap()</span>`<span style="white-space: pre-wrap;"> method instead of </span>`<span class="editor-theme-code">createMap()</span>`.</p>

## Why two steps?

1. **Performance:**<span style="white-space: pre-wrap;"> You can register worlds when the server starts, but only load them when a player starts a minigame.</span>
2. **Security:**<span style="white-space: pre-wrap;"> You can set flags (e.g., PvP off) before the first player enters the world.</span>