Package net.minestom.server
Class UpdateManager
java.lang.Object
net.minestom.server.UpdateManager
public final class UpdateManager
extends java.lang.Object
Manager responsible for the server ticks.
The ThreadProvider
manages the multi-thread aspect for Instance
ticks,
it can be modified with setThreadProvider(ThreadProvider)
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
UpdateManager()
Should only be created in MinecraftServer. -
Method Summary
Modifier and Type Method Description void
addTickEndCallback(java.util.function.LongConsumer callback)
Adds a callback executed at the end of the next server tick.void
addTickStartCallback(java.util.function.LongConsumer callback)
Adds a callback executed at the start of the next server tick.ThreadProvider
getThreadProvider()
Gets the currentThreadProvider
.void
removeTickEndCallback(java.util.function.LongConsumer callback)
Removes a tick end callback.void
removeTickStartCallback(java.util.function.LongConsumer callback)
Removes a tick start callback.void
setThreadProvider(ThreadProvider threadProvider)
Changes the serverThreadProvider
.void
signalChunkLoad(Instance instance, int chunkX, int chunkZ)
Signals theThreadProvider
that a chunk has been loaded.void
signalChunkUnload(Instance instance, int chunkX, int chunkZ)
Signals theThreadProvider
that a chunk has been unloaded.void
signalInstanceCreate(Instance instance)
Signals theThreadProvider
that an instance has been created.void
signalInstanceDelete(Instance instance)
Signals theThreadProvider
that an instance has been deleted.protected void
start()
Starts the server loop in the update thread.void
stop()
Stops the server loop.
-
Constructor Details
-
UpdateManager
protected UpdateManager()Should only be created in MinecraftServer.
-
-
Method Details
-
start
protected void start()Starts the server loop in the update thread. -
getThreadProvider
Gets the currentThreadProvider
.- Returns:
- the current thread provider
-
setThreadProvider
Changes the serverThreadProvider
.- Parameters:
threadProvider
- the new thread provider- Throws:
java.lang.NullPointerException
- ifthreadProvider
is null
-
signalInstanceCreate
Signals theThreadProvider
that an instance has been created.WARNING: should be automatically done by the
InstanceManager
.- Parameters:
instance
- the instance
-
signalInstanceDelete
Signals theThreadProvider
that an instance has been deleted.WARNING: should be automatically done by the
InstanceManager
.- Parameters:
instance
- the instance
-
signalChunkLoad
Signals theThreadProvider
that a chunk has been loaded.WARNING: should be automatically done by the
Instance
implementation.- Parameters:
instance
- the instance of the chunkchunkX
- the chunk XchunkZ
- the chunk Z
-
signalChunkUnload
Signals theThreadProvider
that a chunk has been unloaded.WARNING: should be automatically done by the
Instance
implementation.- Parameters:
instance
- the instance of the chunkchunkX
- the chunk XchunkZ
- the chunk Z
-
addTickStartCallback
public void addTickStartCallback(@NotNull java.util.function.LongConsumer callback)Adds a callback executed at the start of the next server tick.The long in the consumer represents the starting time (in ms) of the tick.
- Parameters:
callback
- the tick start callback
-
removeTickStartCallback
public void removeTickStartCallback(@NotNull java.util.function.LongConsumer callback)Removes a tick start callback.- Parameters:
callback
- the callback to remove
-
addTickEndCallback
public void addTickEndCallback(@NotNull java.util.function.LongConsumer callback)Adds a callback executed at the end of the next server tick.The long in the consumer represents the duration (in ms) of the tick.
- Parameters:
callback
- the tick end callback
-
removeTickEndCallback
public void removeTickEndCallback(@NotNull java.util.function.LongConsumer callback)Removes a tick end callback.- Parameters:
callback
- the callback to remove
-
stop
public void stop()Stops the server loop.
-