Skip to content

API reference / @jsprismarine/prismarine / WorldManager

Class: WorldManager ​

Defined in: prismarine/src/world/WorldManager.ts:65

Loads and unloads levels, one per worlds.<name> entry, and answers which world of the default level holds a dimension.

Implements ​

Constructors ​

Constructor ​

new WorldManager(server): WorldManager

Defined in: prismarine/src/world/WorldManager.ts:81

Parameters ​

server ​

Server

Returns ​

WorldManager

Methods ​

addProvider() ​

addProvider(name, provider): void

Defined in: prismarine/src/world/WorldManager.ts:164

Add a provider to the internal providers map.

Parameters ​

name ​

string

the name of the provider CASE SENSITIVE

provider ​

ProviderClass

the provider class, constructed per world with its folder path and the server

Returns ​

void


getDefaultLevel() ​

getDefaultLevel(): Level

Defined in: prismarine/src/world/WorldManager.ts:444

The level-name level, which players join and whose dimensions the commands address.

Returns ​

Level


getDefaultWorld() ​

getDefaultWorld(): World

Defined in: prismarine/src/world/WorldManager.ts:534

Returns the default world.

Returns ​

World

the world instance.


getGeneratorFactories() ​

getGeneratorFactories(): GeneratorFactories

Defined in: prismarine/src/world/WorldManager.ts:539

The generator kinds this server can build a dimension with.

Returns ​

GeneratorFactories


getLevel() ​

getLevel(folderName): Level | undefined

Defined in: prismarine/src/world/WorldManager.ts:430

The loaded level of a folder name, compared case-insensitively, or undefined.

Parameters ​

folderName ​

string

Returns ​

Level | undefined


getLevels() ​

getLevels(): Level[]

Defined in: prismarine/src/world/WorldManager.ts:439

Every loaded level, in load order.

Returns ​

Level[]


getProviders() ​

getProviders(): Map<string, ProviderClass>

Defined in: prismarine/src/world/WorldManager.ts:180

Get all registered provider classes by name.

Returns ​

Map<string, ProviderClass>


getWorldByDimension() ​

getWorldByDimension(dimension): World | undefined

Defined in: prismarine/src/world/WorldManager.ts:463

The default level's loaded world of a dimension, without building one.

Parameters ​

dimension ​

string

A Java dimension_type id such as minecraft:the_nether, or the Bedrock spelling of a vanilla one, which is how the content runtime keys its worlds.

Returns ​

World | undefined

The world, or undefined before the default level exists or while that dimension is still lazy.


getWorldByName() ​

getWorldByName(folderName): World | null

Defined in: prismarine/src/world/WorldManager.ts:451

The Overworld of the level with that folder name, or null when none is loaded.

Parameters ​

folderName ​

string

Returns ​

World | null


isWorldLoaded() ​

isWorldLoaded(folderName): boolean

Defined in: prismarine/src/world/WorldManager.ts:425

Whether a level of that folder name is loaded.

Parameters ​

folderName ​

string

Returns ​

boolean

true if the level is loaded, false otherwise


loadLevel() ​

loadLevel(worldData, folderName): Promise<Level>

Defined in: prismarine/src/world/WorldManager.ts:203

Loads a level: resolves its stems, opens its save, builds its eager worlds and writes the stems into a save that had none.

Parameters ​

worldData ​

WorldData

The worlds.<name> entry: provider key, preset, seed, dimensions.

folderName ​

string

The folder under worlds/ the level lives in.

Returns ​

Promise<Level>

Throws ​

When the level is already loaded, names a provider that is not registered, or its stems cannot be resolved.


removeProvider() ​

removeProvider(name): void

Defined in: prismarine/src/world/WorldManager.ts:173

Remove a provider from the internal providers map.

Parameters ​

name ​

string

the name of the provider CASE SENSITIVE

Returns ​

void


save() ​

save(): Promise<void>

Defined in: prismarine/src/world/WorldManager.ts:187

Saves every loaded level to disk.

Returns ​

Promise<void>


startWorld() ​

startWorld(dimension): World | undefined

Defined in: prismarine/src/world/WorldManager.ts:502

The default level's world of a dimension, starting its build when nobody has entered it.

For a caller that cannot wait, such as a command writing blocks. The world answered may still be enabling, in which case it has no chunks loaded and a block read finds nothing, the way Java answers "That position is not loaded" for a dimension nobody is in. A caller that used to fall back to the default world here wrote the Nether's blocks into the Overworld instead.

Parameters ​

dimension ​

string

A Java dimension_type id, or the Bedrock spelling of a vanilla one.

Returns ​

World | undefined

The world, or undefined when no stem of the default level has that dimension.


unloadWorld() ​

unloadWorld(folderName): Promise<void>

Defined in: prismarine/src/world/WorldManager.ts:407

Unloads a level by its folder name: every world of it saves and closes, then its provider.

Parameters ​

folderName ​

string

Returns ​

Promise<void>


worldFor() ​

worldFor(dimension): Promise<World>

Defined in: prismarine/src/world/WorldManager.ts:479

The default level's world of a dimension, built and enabled if it is not yet.

Parameters ​

dimension ​

string

A Java dimension_type id, or the Bedrock spelling of a vanilla one.

Returns ​

Promise<World>

Throws ​

When no stem of the default level has that dimension, naming the ones that do, or when the stem's generator cannot be built.

Lifecycle ​

disable() ​

disable(): Promise<void>

Defined in: prismarine/src/world/WorldManager.ts:153

On disable hook.

Signifies that the manager is being disabled and all worlds should be unloaded.

Returns ​

Promise<void>

Implementation of ​

Service.disable


enable() ​

enable(): Promise<void>

Defined in: prismarine/src/world/WorldManager.ts:101

On enable hook: loads every worlds.* entry as a level, the level-name one first.

Returns ​

Promise<void>

Throws ​

When level-name is empty or names no worlds entry.

Implementation of ​

Service.enable