Interface WorldManager
public interface WorldManager
The worlds of the server: loading, creating and unloading them, and what they share (base game
rules, datapack structures).
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCollection<? extends World> all()Gets the worlds currently loaded.Creates a new world from the given specification.default Worldcreate(Key key, WorldGenerator generator) Creates a new world driven by the given generator, with a seed of0.Returns the key of the world currently preferred as the server's default, or Optional.empty() if none is configured.voiddefaultWorld(@Nullable Key key) Sets the world that should be preferred as the server's default when resolving a fallback world for players and commands with no other context.The base game rules of the server: the overworld's, which every world follows unless it overrides them throughWorld.gameRules().Looks up a loaded world.Datapack structures: packs of<world>/datapacks, templates, jigsaw structures, placement and/locate-style search.booleanUnloads the world identified bykey, optionally saving it to disk first.
-
Method Details
-
all
Collection<? extends World> all()Gets the worlds currently loaded.- Returns:
- the loaded worlds
- Since:
- 0.1.0
-
get
-
create
Creates a new world from the given specification.If a world is already registered under the spec's key, that existing world is returned unchanged and the rest of the spec (seed, generator) is ignored; this call is therefore idempotent with respect to the world key. Otherwise a new world is registered using the spec's generator, or the server's built-in default generator when the spec supplies none.
The returned world is immediately usable: it participates in ticking and its chunks are generated on demand through the configured generator.
- Parameters:
spec- the description of the world to create- Returns:
- the newly created world, or the existing world sharing the same key
- Since:
- 0.1.0
-
create
Creates a new world driven by the given generator, with a seed of0.- Parameters:
key- the world keygenerator- the chunk generator to drive the new world- Returns:
- the newly created world, or the existing world sharing the same key
- Since:
- 0.1.0
- See Also:
-
unload
Unloads the world identified bykey, optionally saving it to disk first.Unloading removes the world from
all()and stops it being ticked; entities it held are released. The call is refused, returningfalsewithout side effects, when:- no world is registered under
key; - the world is the only one currently loaded; at least one world must always remain; or
- players are still present in the world; relocate them with another world first.
- Parameters:
key- the key of the world to unloadsave- whether to save the world before unloading it- Returns:
trueif the world was unloaded,falseif the call was refused- Since:
- 0.1.0
- no world is registered under
-
defaultWorld
Returns the key of the world currently preferred as the server's default, or Optional.empty() if none is configured.- Returns:
- the key of the world currently preferred as the server's default, or Optional.empty() if none is configured
- Since:
- 0.1.0
-
defaultWorld
Sets the world that should be preferred as the server's default when resolving a fallback world for players and commands with no other context.- Parameters:
key- the key of the preferred world, ornullto clear the preference- Since:
- 0.1.0
-
gameRules
GameRules gameRules()The base game rules of the server: the overworld's, which every world follows unless it overrides them throughWorld.gameRules().- Returns:
- the base game rules, as changed by
/gamerule <rule> <value> - Since:
- 0.1.0
-
structures
StructureManager structures()Datapack structures: packs of<world>/datapacks, templates, jigsaw structures, placement and/locate-style search.- Returns:
- the structure manager of the server
- Since:
- 0.1.0
-