Documentation

WorldManager
in package

Table of Contents

$autoSave  : bool
$autoSaveTicker  : int
$autoSaveTicks  : int
$dataPath  : string
$defaultWorld  : World|null
$providerManager  : WorldProviderManager
$server  : Server
$worlds  : array<string|int, World>
__construct()  : mixed
findEntity()  : Entity|null
Searches all worlds for the entity with the specified ID.
generateWorld()  : bool
Generates a new world if it does not exist
getAutoSave()  : bool
getAutoSaveInterval()  : int
Returns the period in ticks after which loaded worlds will be automatically saved to disk.
getDefaultWorld()  : World|null
getProviderManager()  : WorldProviderManager
getWorld()  : World|null
getWorldByName()  : World|null
NOTE: This matches worlds based on the FOLDER name, NOT the display name.
getWorlds()  : array<string|int, World>
isWorldGenerated()  : bool
isWorldLoaded()  : bool
loadWorld()  : bool
Loads a world from the data directory
setAutoSave()  : void
setAutoSaveInterval()  : void
setDefaultWorld()  : void
Sets the default world to a different world This won't change the level-name property, it only affects the server on runtime
tick()  : void
unloadWorld()  : bool
doAutoSave()  : void
getWorldPath()  : string

Properties

Methods

findEntity()

Searches all worlds for the entity with the specified ID.

public findEntity(int $entityId) : Entity|null

Useful for tracking entities across multiple worlds without needing strong references.

Parameters
$entityId : int
Return values
Entity|null

generateWorld()

Generates a new world if it does not exist

public generateWorld(string $name, WorldCreationOptions $options[, bool $backgroundGeneration = true ]) : bool
Parameters
$name : string
$options : WorldCreationOptions
$backgroundGeneration : bool = true
Tags
throws
InvalidArgumentException
Return values
bool

getAutoSave()

public getAutoSave() : bool
Return values
bool

getAutoSaveInterval()

Returns the period in ticks after which loaded worlds will be automatically saved to disk.

public getAutoSaveInterval() : int
Return values
int

getWorld()

public getWorld(int $worldId) : World|null
Parameters
$worldId : int
Return values
World|null

getWorldByName()

NOTE: This matches worlds based on the FOLDER name, NOT the display name.

public getWorldByName(string $name) : World|null
Parameters
$name : string
Return values
World|null

isWorldGenerated()

public isWorldGenerated(string $name) : bool
Parameters
$name : string
Return values
bool

isWorldLoaded()

public isWorldLoaded(string $name) : bool
Parameters
$name : string
Return values
bool

loadWorld()

Loads a world from the data directory

public loadWorld(string $name[, bool $autoUpgrade = false ]) : bool
Parameters
$name : string
$autoUpgrade : bool = false

Converts worlds to the default format if the world's format is not writable / deprecated

Tags
throws
WorldException
Return values
bool

setAutoSave()

public setAutoSave(bool $value) : void
Parameters
$value : bool
Return values
void

setAutoSaveInterval()

public setAutoSaveInterval(int $autoSaveTicks) : void
Parameters
$autoSaveTicks : int
Return values
void

setDefaultWorld()

Sets the default world to a different world This won't change the level-name property, it only affects the server on runtime

public setDefaultWorld(World|null $world) : void
Parameters
$world : World|null
Return values
void

tick()

public tick(int $currentTick) : void
Parameters
$currentTick : int
Return values
void

unloadWorld()

public unloadWorld(World $world[, bool $forceUnload = false ]) : bool
Parameters
$world : World
$forceUnload : bool = false
Tags
throws
InvalidArgumentException
Return values
bool

doAutoSave()

private doAutoSave() : void
Return values
void

getWorldPath()

private getWorldPath(string $name) : string
Parameters
$name : string
Return values
string

Search results