Play Strawberry Docs
Scripts

Game updates and your worlds

Declare the worlds your game makes, so a new version of your game ships new maps while players keep their progress.

What happens on an update

A world your game makes with its own generator is written into chunks the first time a player comes near them. Without a declaration, a server that already has those chunks keeps the old maps after you ship a new version, and only a world reset would show the new ones.

Declare the worlds your game makes and give them a revision. When the server starts with a version of your game whose revision differs from the one those worlds were made with, it makes them again: their old chunks move into a backup, and your generator makes them fresh with the new maps. Nobody has to reset anything; the update and its restart are enough.

What stays, always:

  • the players' own files: inventory, position, stats and advancements;
  • your script's data folder and everything it saved, and the players' progress your game keeps there;
  • the world's settings and the data saved with it: the seed, game rules, scoreboards and the values your game set on the world;
  • every world you did not declare.

What is made again: the blocks, entities and points of interest of the worlds you declared, in all their dimensions.

Declare the worlds your game makes

Put a file game-worlds.json next to your Cargo.toml:

json
{"format": "strawberry-game-worlds/1", "revision": 1, "worlds": ["world"]}
  • revision: a whole number from 0 to 2147483647. Raise it in the version whose maps change. A version that changes only code keeps it, and the worlds stay as they are.
  • worlds: the worlds your game makes itself, 1 to 64 names. world is the server's main world, with its Nether and End; any other name is a world your game creates with create_world (the same name).

Then put the file into your build with one line, once, at the top of your crate (the path is relative to your Cargo.toml):

rust
strawberry_plugin_api::game_worlds!("game-worlds.json");

A declaration the server would not use does not build: the compiler stops with the reason, for example a world name with a / or a key other than format, revision and worlds. To check the file in a test, call strawberry_plugin_api::game_worlds::check(include_bytes!("../game-worlds.json")): it applies exactly the server's rules and gives the revision and the worlds, or what is wrong and which name it is about.

A world name has 1 to 64 characters (letters, digits, _, . and -, not starting with . or -), and each name appears once. The names of the main world's own folders (such as region, playerdata or level.dat), templates, sessions and names starting with session- are refused, whatever their case.

Please note

Declare only the worlds your game makes on its own. Whatever players build in a declared world is made again too, on every new revision. Keep the places players build in a world you do not declare.

Players in a world that changed

A player comes back where they left. After new maps, that place may be inside a wall. Send players to a safe place of the new map when they join, for example the level's start, from your join handler.

The first start of a version that declares worlds on a server that already has them makes them again once, because the server does not know which version made them.

For the server owner: the way back

The old chunks are kept in the folder world-backups of the server, one folder per world and update (<time>-<world>), with about.json saying which version made them. The newest three of each world stay; older ones are removed. To go back to the old maps, stop the server and move the folders of a backup back into the world folder.

On this page