Skip to main content

2. Create worlds (Builder)

In GWorld v2v2, werdennew neueworlds Weltenare übercreated dasusing the Builder-Patternbuilder pattern. erstellt.This Diesseparates trennt diethe Konfigurationconfiguration (Registrierung)registration) vonfrom derthe Generierunggeneration (Last)load).

SchrittStep 1: DerThe Builder (Registrierung)Registration)

MitWith demthe WorldCreationBuilder you legstdefine duall allethe Eigenschaftenproperties derof Weltthe fest.world. Der Aufruf vonCalling .build() registriertregisters diethe Weltworld in derthe Datenbank,database, erstelltbut siedoes abernot nochyet nichtphysically physikalisch.create it.

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

// StartetStart denthe Builderbuilder
IManageableWorld newWorld = worldManager.createBuilder("MeineEventWelt")
    .worldType(WorldTypeMapping.NORMAL) // Umgebung:Environent: Normal, Nether, End, Large Biomes, Amplified, Flat
    .generator("PlotSquared")           // Optional: Custom Generator Name
    .seed(987654321L)                   // Optional: SeedSet festlegenseed
    .build();                           // -> SpeichertSaves diethe Weltworld in dieto Config/DB

Hinweis:Note: Die MethodeThe .build() ruftmethod interninternally calls addWorldFromBuilder. auf.The Dieworld Weltis istthen danach bekanntknown (registered), aberbut nochstill unloaded.

SchrittStep 2: LadenLoad (Generierung)generation)

// ErstelltCreates diethe Bukkit-Weltbukkit undworld lädtand Chunksloads chunks
boolean success = newWorld.createMap(); 

if (success) {
  getLogger().info("WeltWorld istis bereit!ready!");
}

FürThe einensame Importapplies giltto diesimports. analog.Use Denthe Ordnernamenfolder dername Weltof verwendenthe undworld anstattand use the `importMap()` method instead of `createMap() die Methode importMap() verwenden.`.

WarumWhy zweitwo Schritte?steps?

  1. Performance: DuYou kannstcan Weltenregister beimworlds Serverstartwhen registrieren,the aberserver erststarts, laden,but wennonly einload Spielerthem einwhen Minigamea startet.player starts a minigame.
  2. Sicherheit:Security: DuYou kannstcan Flagsset flags (z. B.e.g., PvP aus)off) setzen,before bevorthe derfirst ersteplayer Spielerenters diethe Welt betritt.world.