Package net.minestom.server.instance
Class InstanceManager
java.lang.Object
net.minestom.server.instance.InstanceManager
Used to register
Instance
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull InstanceContainer
Creates and register anInstanceContainer
.@NotNull InstanceContainer
createInstanceContainer
(@Nullable IChunkLoader loader) @NotNull InstanceContainer
createInstanceContainer
(DynamicRegistry.Key<DimensionType> dimensionType) @NotNull InstanceContainer
createInstanceContainer
(DynamicRegistry.Key<DimensionType> dimensionType, @Nullable IChunkLoader loader) Creates and register anInstanceContainer
with the specifiedDimensionType
.@NotNull SharedInstance
createSharedInstance
(@NotNull InstanceContainer instanceContainer) Creates and register aSharedInstance
.@Nullable Instance
getInstance
(@NotNull UUID uuid) Gets an instance by the given UUID.Gets all the registered instances.void
registerInstance
(@NotNull Instance instance) Registers anInstance
internally.@NotNull SharedInstance
registerSharedInstance
(@NotNull SharedInstance sharedInstance) Registers aSharedInstance
.void
unregisterInstance
(@NotNull Instance instance) Unregisters theInstance
internally.
-
Constructor Details
-
InstanceManager
-
-
Method Details
-
registerInstance
Registers anInstance
internally.Note: not necessary if you created your instance using
createInstanceContainer()
orcreateSharedInstance(InstanceContainer)
but only if you instantiated your instance object manually- Parameters:
instance
- theInstance
to register
-
createInstanceContainer
@NotNull public @NotNull InstanceContainer createInstanceContainer(@NotNull DynamicRegistry.Key<DimensionType> dimensionType, @Nullable @Nullable IChunkLoader loader) Creates and register anInstanceContainer
with the specifiedDimensionType
.- Parameters:
dimensionType
- theDimensionType
of the instanceloader
- the chunk loader- Returns:
- the created
InstanceContainer
-
createInstanceContainer
@NotNull public @NotNull InstanceContainer createInstanceContainer(@NotNull DynamicRegistry.Key<DimensionType> dimensionType) -
createInstanceContainer
@NotNull public @NotNull InstanceContainer createInstanceContainer(@Nullable @Nullable IChunkLoader loader) -
createInstanceContainer
Creates and register anInstanceContainer
.- Returns:
- the created
InstanceContainer
-
unregisterInstance
Unregisters theInstance
internally.If
instance
is anInstanceContainer
all chunks are unloaded.- Parameters:
instance
- theInstance
to unregister
-
getInstances
Gets all the registered instances.- Returns:
- an unmodifiable
Set
containing all the registered instances
-
getInstance
Gets an instance by the given UUID.- Parameters:
uuid
- UUID of the instance- Returns:
- the instance with the given UUID, null if not found
-