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
$autoSave
private
bool
$autoSave
= true
$autoSaveTicker
private
int
$autoSaveTicker
= 0
$autoSaveTicks
private
int
$autoSaveTicks
= 6000
$dataPath
private
string
$dataPath
$defaultWorld
private
World|null
$defaultWorld
$providerManager
private
WorldProviderManager
$providerManager
$server
private
Server
$server
$worlds
private
array<string|int, World>
$worlds
= []
Methods
__construct()
public
__construct(Server $server, string $dataPath, WorldProviderManager $providerManager) : mixed
Parameters
- $server : Server
- $dataPath : string
- $providerManager : WorldProviderManager
Return values
mixed —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
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 —getDefaultWorld()
public
getDefaultWorld() : World|null
Return values
World|null —getProviderManager()
public
getProviderManager() : WorldProviderManager
Return values
WorldProviderManager —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 —getWorlds()
public
getWorlds() : array<string|int, World>
Return values
array<string|int, World> —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
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
Return values
bool —doAutoSave()
private
doAutoSave() : void
Return values
void —getWorldPath()
private
getWorldPath(string $name) : string
Parameters
- $name : string