Package net.minestom.server.instance
Class InstanceManager
java.lang.Object
net.minestom.server.instance.InstanceManager
public final class InstanceManager
extends java.lang.Object
Used to register
Instance
.-
Constructor Summary
Constructors Constructor Description InstanceManager()
-
Method Summary
Modifier and Type Method Description InstanceContainer
createInstanceContainer()
Creates and register anInstanceContainer
.InstanceContainer
createInstanceContainer(StorageLocation storageLocation)
Creates and register anInstanceContainer
with the specifiedStorageLocation
.InstanceContainer
createInstanceContainer(DimensionType dimensionType)
Creates and register anInstanceContainer
with the specifiedDimensionType
.InstanceContainer
createInstanceContainer(DimensionType dimensionType, StorageLocation storageLocation)
SharedInstance
createSharedInstance(InstanceContainer instanceContainer)
Creates and register aSharedInstance
.java.util.Set<Instance>
getInstances()
Gets all the registered instances.void
registerInstance(Instance instance)
Registers anInstance
internally.SharedInstance
registerSharedInstance(SharedInstance sharedInstance)
Registers aSharedInstance
.void
unregisterInstance(Instance instance)
Unregisters theInstance
internally.
-
Constructor Details
-
InstanceManager
public 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 InstanceContainer createInstanceContainer(@NotNull DimensionType dimensionType, @Nullable StorageLocation storageLocation)- Parameters:
dimensionType
- theDimensionType
of the instancestorageLocation
- theStorageLocation
of the instance, can be null- Returns:
- the created
InstanceContainer
-
createInstanceContainer
@NotNull public InstanceContainer createInstanceContainer(@Nullable StorageLocation storageLocation)Creates and register anInstanceContainer
with the specifiedStorageLocation
.- Parameters:
storageLocation
- theStorageLocation
of the instance, can be null- Returns:
- the created
InstanceContainer
-
createInstanceContainer
Creates and register anInstanceContainer
with the specifiedDimensionType
.- Parameters:
dimensionType
- theDimensionType
of the instance- Returns:
- the created
InstanceContainer
-
createInstanceContainer
Creates and register anInstanceContainer
.- Returns:
- the created
InstanceContainer
-
registerSharedInstance
Registers aSharedInstance
.WARNING: the
SharedInstance
needs to have anInstanceContainer
assigned to it.- Parameters:
sharedInstance
- theSharedInstance
to register- Returns:
- the registered
SharedInstance
- Throws:
java.lang.NullPointerException
- ifsharedInstance
doesn't have anInstanceContainer
assigned to it
-
createSharedInstance
Creates and register aSharedInstance
.- Parameters:
instanceContainer
- the container assigned to the shared instance- Returns:
- the created
SharedInstance
- Throws:
java.lang.IllegalStateException
- ifinstanceContainer
is not registered
-
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
-