Package net.minestom.server.thread
Class PerInstanceThreadProvider
java.lang.Object
net.minestom.server.thread.ThreadProvider
net.minestom.server.thread.PerInstanceThreadProvider
public class PerInstanceThreadProvider extends ThreadProvider
Separates work between instance (1 instance = 1 thread execution).
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PerInstanceThreadProvider()
-
Method Summary
Modifier and Type Method Description void
onChunkLoad(Instance instance, int chunkX, int chunkZ)
Called when a chunk is loaded.void
onChunkUnload(Instance instance, int chunkX, int chunkZ)
Called when a chunk is unloaded.void
onInstanceCreate(Instance instance)
Called when anInstance
is registered.void
onInstanceDelete(Instance instance)
Called when anInstance
is unregistered.java.util.List<java.util.concurrent.Future<?>>
update(long time)
Performs a server tick for all chunks based on their linked thread.Methods inherited from class net.minestom.server.thread.ThreadProvider
conditionalEntityUpdate, getThreadCount, processChunkTick, setThreadCount, updateChunk, updateCreatures, updateEntities, updateInstance, updateLivingEntities, updateObjectEntities, updatePlayers
-
Constructor Details
-
PerInstanceThreadProvider
public PerInstanceThreadProvider()
-
-
Method Details
-
onInstanceCreate
Description copied from class:ThreadProvider
Called when anInstance
is registered.- Specified by:
onInstanceCreate
in classThreadProvider
- Parameters:
instance
- the newly createInstance
-
onInstanceDelete
Description copied from class:ThreadProvider
Called when anInstance
is unregistered.- Specified by:
onInstanceDelete
in classThreadProvider
- Parameters:
instance
- the deletedInstance
-
onChunkLoad
Description copied from class:ThreadProvider
Called when a chunk is loaded.Be aware that this is possible for an instance to load chunks before being registered.
- Specified by:
onChunkLoad
in classThreadProvider
- Parameters:
instance
- the instance of the chunkchunkX
- the chunk XchunkZ
- the chunk Z
-
onChunkUnload
Description copied from class:ThreadProvider
Called when a chunk is unloaded.- Specified by:
onChunkUnload
in classThreadProvider
- Parameters:
instance
- the instance of the chunkchunkX
- the chunk XchunkZ
- the chunk Z
-
update
@NotNull public java.util.List<java.util.concurrent.Future<?>> update(long time)Description copied from class:ThreadProvider
Performs a server tick for all chunks based on their linked thread.- Specified by:
update
in classThreadProvider
- Parameters:
time
- the update time in milliseconds- Returns:
- the futures to execute to complete the tick
-