# Migration from v1-legacy to v2

GWorld v2 features intelligent migration systems that make the transition from older versions or the change between storage media (files to database) as easy as possible.

**Are you looking for a way to switch from YAML to MySQL? Then please follow this link:** [**Switch from YAML (File) to MySQL (DB)**](https://books.gilljan.de/books/gworld-dokumentation-de/page/wechsel-von-yaml-file-zu-mysql-db)

---

## Migration from GWorld v1 to v2

When you upgrade from the first version of GWorld to v2, the plugin will automatically detect this during the first start.

### How it works

- **Detection:**<span style="white-space: pre-wrap;"> The plugin looks for an existing </span>`<span class="editor-theme-code">worlds.yml</span>`<span style="white-space: pre-wrap;"> where...</span>
    - <span style="white-space: pre-wrap;">the </span>`<span class="editor-theme-code">ConfigVersion</span>`<span style="white-space: pre-wrap;"> field is missing</span>
    - <span style="white-space: pre-wrap;">the </span>`<span class="editor-theme-code">LoadWorlds</span>`<span style="white-space: pre-wrap;"> list exists</span>
    - <span style="white-space: pre-wrap;">the </span>`<span class="editor-theme-code">Worlds</span>`<span style="white-space: pre-wrap;"> list exists</span>
- **Automatic Backup:**<span style="white-space: pre-wrap;"> Before changes are made to the datasets, GWorld renames the old file to </span>`<span class="editor-theme-code">worlds_legacy_backup.yml</span>`.
- **Data Conversion:**<span style="white-space: pre-wrap;"> The </span>`<span class="editor-theme-code">LegacyMigrator</span>`<span style="white-space: pre-wrap;"> reads all old world definitions and transfers them into the new, structured </span>**v2 format**. Missing new fields are filled with default values.
- **Seed Repair:**<span style="white-space: pre-wrap;"> Since seeds were not saved in v1, GWorld v2 automatically detects missing seeds when the world is first loaded, reads the correct seed from the world files, and corrects the entry.</span>

<p class="callout info">**Note:**<span style="white-space: pre-wrap;"> During the migration, the console will inform you about the progress. Once the </span>`<span class="editor-theme-code">worlds.yml</span>`<span style="white-space: pre-wrap;"> file contains a </span>`<span class="editor-theme-code">ConfigVersion: 1</span>`, the process is complete. This will also be output in the console.</p>

<p class="callout success">After a successful migration, GWorld v2 starts normally and all worlds are loaded.</p>

### Security Measures &amp; Prerequisites

To ensure a smooth migration, please note the following points:

#### <span style="white-space: pre-wrap;">Prerequisites (see </span>[Introduction](https://books.gilljan.de/books/gworld-dokumentation-de/page/einfuhrung))

- **Java Version:**<span style="white-space: pre-wrap;"> GWorld v2 strictly requires at least </span>**Java 21**, as modern language features are used.

#### Checklist

- [ ] Create a manual backup of your entire plugin folder before upgrading.
- [ ] <span style="white-space: pre-wrap;">After the migration, check with the command </span>`<span class="editor-theme-code">/gworlds</span>`<span style="white-space: pre-wrap;"> whether all worlds are listed correctly.</span>
- [ ] Check the server console for error messages during the first start.

---

### Example worlds.yml Configurations

<table id="bkmrk-worlds.yml-%28v1%29world" style="border-width: 1px; border-style: hidden;"><colgroup><col style="width: 10px;"></col><col style="width: 570px;"></col></colgroup><tbody><tr><td>**worlds.yml (v1)**

</td><td>**worlds.yml (v2.0.0)**

</td></tr><tr><td>```YAML
#Copyright (c) Gilljan 2020-2022. All rights reserved.
#Plugin written by Gilljan
LoadWorlds:
  - world
  - world_nether
  - world_the_end


Worlds:
  world:
    generator: 'null'
    type: normal
    timeCycle: true
    time: 6000
    weatherCycle: true
    weather: sun
    pvp: true
    mobs: true
    animals: true
    forcedGamemode: false
    defaultGamemode: SURVIVAL
    difficulty: NORMAL
    randomTickSpeed: 3
    announceAdvancements: true
  world_nether:
    generator: 'null'
    type: nether
    timeCycle: true
    time: 6000
    weatherCycle: true
    weather: sun
    pvp: true
    mobs: true
    animals: true
    forcedGamemode: false
    defaultGamemode: SURVIVAL
    difficulty: NORMAL
    randomTickSpeed: 3
    announceAdvancements: true
  world_the_end:
    generator: 'null'
    type: end
    timeCycle: true
    time: 6000
    weatherCycle: true
    weather: sun
    pvp: true
    mobs: true
    animals: true
    forcedGamemode: false
    defaultGamemode: SURVIVAL
    difficulty: NORMAL
    randomTickSpeed: 3
    announceAdvancements: true
```

</td><td>```YAML
ConfigVersion: 1

Worlds:
  world:
    Environment: NORMAL
    Alias: §bMy world
    Type: NORMAL
    Seed: 541091381232416907
    AllowPvP: true
    KeepSpawnInMemory: true
    AnimalSpawning: true
    DisabledAnimals:
    - cow
    MonsterSpawning: false
    DisabledMonsters:
    - spider
    WeatherCycle: false
    WeatherType: CLEAR
    TimeCycle: false
    Time: 6000
    DefaultGamemode: false
    GameMode: ADVENTURE
    Difficulty: HARD
    LoadOnStartup: true
    RandomTickSpeed: 3
    AnnounceAdvancements: true
  world_nether:
    Environment: NETHER
    Alias: §cThe nether
    Type: NORMAL
    Seed: 541091381232416907
    AllowPvP: true
    KeepSpawnInMemory: true
    AnimalSpawning: true
    DisabledAnimals: []
    MonsterSpawning: true
    DisabledMonsters: []
    WeatherCycle: true
    WeatherType: CLEAR
    TimeCycle: true
    Time: 0
    DefaultGamemode: false
    GameMode: SURVIVAL
    Difficulty: NORMAL
    LoadOnStartup: false
    RandomTickSpeed: 3
    AnnounceAdvancements: true
  world_the_end:
    Environment: THE_END
    Alias: §6The END
    Type: NORMAL
    Seed: 541091381232416907
    AllowPvP: true
    KeepSpawnInMemory: true
    AnimalSpawning: true
    DisabledAnimals: []
    MonsterSpawning: true
    DisabledMonsters: []
    WeatherCycle: true
    WeatherType: CLEAR
    TimeCycle: true
    Time: 0
    DefaultGamemode: false
    GameMode: SURVIVAL
    Difficulty: NORMAL
    LoadOnStartup: false
    RandomTickSpeed: 3
    AnnounceAdvancements: true
```

</td></tr></tbody></table>

---

**This documentation refers to GWorld version 2.0.1.**