Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- init()
- stopIndividualWorld()
- stopIndividualWorld(Map)
- validateDeleteOnRemove()
- setTps(int)
- setTimeDilation(float, ComponentAccessor)
- getName()
- isAlive()
- getWorldConfig()
- getDeathConfig()
- getGameModeTypeOnDeath()
- getDaytimeDurationSeconds()
- getNighttimeDurationSeconds()
- isTicking()
- setTicking(boolean)
- isPaused()
- setPaused(boolean)
- getTick()
- getLogger()
- isCompassUpdating()
- setCompassUpdating(boolean)
- getPlayers()
- getEntity(UUID)
- getEntityRef(UUID)
- getPlayerCount()
- getNonSpectatorPlayerCount()
- getPlayerRefs()
- trackPlayerRef(PlayerRef)
- untrackPlayerRef(PlayerRef)
- spawnEntity(T, Vector3d, Rotation3f)
- addEntity(T, Vector3d, Rotation3f, AddReason)
- sendMessage(Message)
- execute(Runnable)
- scheduleAfter(Runnable, long, TimeUnit)
- consumeTaskQueue()
- getChunkStore()
- getEntityStore()
- getChunkLighting()
- getWorldMapManager()
- getWorldPathConfig()
- getNotificationHandler()
- getEventRegistry()
- addPlayer(PlayerRef)
- addPlayer(PlayerRef, Transform)
- addPlayer(PlayerRef, Transform, Boolean, Boolean)
- resendGameplayConfig()
- drainPlayersTo(World, Collection, Message, boolean)
- getGameplayConfig()
- getFeatures()
- isFeatureEnabled(ClientFeature)
- registerFeature(ClientFeature, boolean)
- broadcastFeatures()
- getSavePath()
- updateEntitySeed(Store)
- markGCHasRun()
- consumeGCHasRun()
- isSavingLocked()
- lockSaving()
- unlockSaving()
- hashCode()
- equals(Object)
- toString()
Class World
java.lang.Object
com.hypixel.hytale.server.core.util.thread.TickingThread
com.hypixel.hytale.server.core.universe.world.World
- All Implemented Interfaces:
ExecutorMetricsRegistry.ExecutorMetric, IMessageReceiver, Runnable, Executor
public class World
extends TickingThread
implements Executor, ExecutorMetricsRegistry.ExecutorMetric, IMessageReceiver
Represents a world instance in the universe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the default world.static final ExecutorMetricsRegistry<World> The metrics registry for theWorldclass.static final floatThe interval, in seconds, between performing saves of the world.Fields inherited from class TickingThread
NANOS_IN_ONE_MILLI, NANOS_IN_ONE_SECOND, SLEEP_OFFSET, TPS -
Constructor Summary
ConstructorsConstructorDescriptionWorld(String name, Path savePath, WorldConfig worldConfig) Default Constructor for aWorldinstance. -
Method Summary
Modifier and TypeMethodDescription<T extends Entity>
TaddEntity(T entity, org.joml.Vector3d position, Rotation3f rotation, AddReason reason) Deprecated.Called to add the given player to this world.Called to add the given player to this world.addPlayer(PlayerRef playerRef, Transform transform, Boolean clearWorldOverride, Boolean fadeInOutOverride) Called to add the given player to this world.voidBroadcasts the current feature state to all players in this world.booleanConsume whether a garbage collection has run since the last time this method was called.voiddrainPlayersTo(World fallbackTargetWorld, Collection<PlayerRef> players, Message message, boolean isRemovalExceptional) Removes all players from this world and either sends them back to the location set in the event or sends them to the providedfallbackTargetWorld.booleanvoidintDeprecated.getEntityRef(UUID uuid) getName()intintThe number of players in this world that are not spectating, for lifecycle decisions that should not let a spectator hold a world open.Get the notification handler used to notify clients of changes to the worldintNote: The returned collection may hold PlayerRefs with invalid/null Refs.Deprecated, for removal: This API element is subject to removal in a future version.longgetTick()Get the world configinthashCode()init()Called to start initializing the world.booleanisAlive()booleanbooleanisFeatureEnabled(ClientFeature feature) Checks if a client feature is enabled for this world.booleanisPaused()booleanWhether saving of this world is prevented due to another process wanting to access the files manually. e.g. backupsbooleanvoidIncrements the saving lock counter, preventing any saving systems from writing to disk.voidCalled to mark that a garbage collection has run in this world.voidregisterFeature(ClientFeature feature, boolean enabled) Registers (enables or disables) a client feature for this world.voidscheduleAfter(Runnable task, long delay, TimeUnit unit) Schedulestaskto run on this world's thread after the given delay, timed off the shared server scheduler.voidsendMessage(Message message) Called to send a message to this receiver.voidsetCompassUpdating(boolean compassUpdating) voidsetPaused(boolean paused) Called to set whether this world is paused or not.voidsetTicking(boolean ticking) Called to set whether this world is ticking or not.static voidsetTimeDilation(float timeDilationModifier, ComponentAccessor<EntityStore> componentAccessor) Set and update time dilation for all connected Players in the world.voidsetTps(int tps) <T extends Entity>
TspawnEntity(T entity, org.joml.Vector3d position, Rotation3f rotation) Deprecated.voidCalled to stop and remove this individual world from the universe.voidstopIndividualWorld(Map<UUID, PlayerRef> players) toString()voidtrackPlayerRef(PlayerRef playerRef) Called to track the given player ref as part of this world.voidDecrements the saving lock counter, allowing saving to resume once all locks are released.voiduntrackPlayerRef(PlayerRef playerRef) Called to untrack the given player ref as part of this world.voidupdateEntitySeed(Store<EntityStore> store) voidMethods inherited from class TickingThread
clearMetrics, debugAssertInTickingThread, getBufferedTickLengthMetricSet, getFailureException, getPossibleFailureCause, getTickStepNanos, getTps, interrupt, isInThread, isStarted, run, start, stopMethods inherited from interface ExecutorMetricsRegistry.ExecutorMetric
isInThread
-
Field Details
-
SAVE_INTERVAL
public static final float SAVE_INTERVALThe interval, in seconds, between performing saves of the world.- See Also:
-
DEFAULT
-
METRICS_REGISTRY
The metrics registry for theWorldclass.
-
-
Constructor Details
-
World
Default Constructor for aWorldinstance.- Parameters:
name- The name given to the world.savePath- The save location for this world.worldConfig- TheWorldConfigof this world.
-
-
Method Details
-
init
Called to start initializing the world.Returns a future that completes when the world is joinable.
- Returns:
- the world instance once initialized.
-
stopIndividualWorld
public void stopIndividualWorld()Called to stop and remove this individual world from the universe. -
stopIndividualWorld
-
validateDeleteOnRemove
public void validateDeleteOnRemove() -
setTps
public void setTps(int tps) - Overrides:
setTpsin classTickingThread
-
setTimeDilation
public static void setTimeDilation(float timeDilationModifier, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Set and update time dilation for all connected Players in the world. This doesn't affect other worlds loaded on the server. WARNING: Setting this to a value other than 1 removes most client timeout to allow for very slow interactions to run eg: at 0.025 time dilation.- Parameters:
timeDilationModifier- The time dilation modifier to set (0.01 - 4).componentAccessor- TheComponentAccessorfor component access.
-
getName
- Returns:
- the name of this world.
-
isAlive
public boolean isAlive()- Returns:
trueif this world is alive,falseotherwise.
-
getWorldConfig
-
getDeathConfig
- Returns:
- the
DeathConfigfor this world, checking for inline overrides first.
-
getGameModeTypeOnDeath
- Returns:
- the gamemode type asset id entered on death, falling back to the server-wide default
when this world's
DeathConfigdoes not set one, ornullfor the normal respawn flow.
-
getDaytimeDurationSeconds
public int getDaytimeDurationSeconds()- Returns:
- the daytime duration in seconds for this world, checking for inline overrides first.
-
getNighttimeDurationSeconds
public int getNighttimeDurationSeconds()- Returns:
- the nighttime duration in seconds for this world, checking for inline overrides first.
-
isTicking
public boolean isTicking()- Returns:
- the save path for this world.
-
setTicking
public void setTicking(boolean ticking) Called to set whether this world is ticking or not.- Parameters:
ticking- Whether the world should be ticking.
-
isPaused
public boolean isPaused()- Returns:
trueif this world is paused,falseotherwise.
-
setPaused
public void setPaused(boolean paused) Called to set whether this world is paused or not.- Parameters:
paused- Whether the world should be paused.
-
getTick
public long getTick()- Returns:
- The tick counter for this world
- See Also:
-
getLogger
- Returns:
- the logger instance for this world.
-
isCompassUpdating
public boolean isCompassUpdating() -
setCompassUpdating
public void setCompassUpdating(boolean compassUpdating) -
getPlayers
Deprecated, for removal: This API element is subject to removal in a future version. -
getEntity
Deprecated. -
getEntityRef
-
getPlayerCount
public int getPlayerCount() -
getNonSpectatorPlayerCount
public int getNonSpectatorPlayerCount()The number of players in this world that are not spectating, for lifecycle decisions that should not let a spectator hold a world open. Players whose entity is not resolvable are counted as present.- Returns:
- the number of non-spectating players in this world.
-
getPlayerRefs
Note: The returned collection may hold PlayerRefs with invalid/null Refs.- Returns:
- a collection of
PlayerRefinstances tracked in this world.
-
trackPlayerRef
-
untrackPlayerRef
-
spawnEntity
@Deprecated @Nullable public <T extends Entity> T spawnEntity(T entity, @Nonnull org.joml.Vector3d position, Rotation3f rotation) Deprecated. -
addEntity
@Deprecated @Nullable public <T extends Entity> T addEntity(T entity, @Nonnull org.joml.Vector3d position, @Nullable Rotation3f rotation, @Nonnull AddReason reason) Deprecated. -
sendMessage
Description copied from interface:IMessageReceiverCalled to send a message to this receiver.- Specified by:
sendMessagein interfaceIMessageReceiver- Parameters:
message- The message to be sent.
-
execute
-
scheduleAfter
Schedulestaskto run on this world's thread after the given delay, timed off the shared server scheduler. Dropped if the world stops accepting tasks before the delay elapses. The returned future cancels the pending dispatch. Once the delay elapses and the task is handed to the world thread, cancelling the future has no effect. -
consumeTaskQueue
public void consumeTaskQueue() -
getChunkStore
- Returns:
- the
ChunkStoreaffiliated with this world.
-
getEntityStore
- Returns:
- the
EntityStoreaffiliated with this world.
-
getChunkLighting
- Returns:
- the
ChunkLightingManageraffiliated with this world.
-
getWorldMapManager
- Returns:
- the
WorldMapTrackeraffiliated with this world.
-
getWorldPathConfig
- Returns:
- the
WorldPathConfigaffiliated with this world.
-
getNotificationHandler
Get the notification handler used to notify clients of changes to the world- Returns:
- the notification handler
-
getEventRegistry
- Returns:
- the
EventRegistryaffiliated with this world.
-
addPlayer
Called to add the given player to this world.- Parameters:
playerRef- ThePlayerRefcomponent of the player to add.- Returns:
- the future that completes with the player ref once added, or
nullif the player cannot be added.
-
addPlayer
@Nullable public CompletableFuture<PlayerRef> addPlayer(@Nonnull PlayerRef playerRef, @Nullable Transform transform) Called to add the given player to this world. -
addPlayer
@Nullable public CompletableFuture<PlayerRef> addPlayer(@Nonnull PlayerRef playerRef, @Nullable Transform transform, @Nullable Boolean clearWorldOverride, @Nullable Boolean fadeInOutOverride) Called to add the given player to this world.- Parameters:
playerRef- ThePlayerRefcomponent of the player to add.transform- TheTransformto spawn the player at, ornullto use the default spawn point.clearWorldOverride- Whether to override clearing the world when the player joins.fadeInOutOverride- Whether to override fading in/out when the player joins.- Returns:
- the future that completes with the player ref once added, or
nullif the player cannot be added.
-
resendGameplayConfig
public void resendGameplayConfig() -
drainPlayersTo
@Nonnull public CompletableFuture<Void> drainPlayersTo(@Nonnull World fallbackTargetWorld, @Nonnull Collection<PlayerRef> players, @Nullable Message message, boolean isRemovalExceptional) Removes all players from this world and either sends them back to the location set in the event or sends them to the providedfallbackTargetWorld.- Parameters:
fallbackTargetWorld- The fallback target world.players- The players to drain.message- The default message sent to each drained player, which event listeners may replace or clear.isRemovalExceptional- Whether this world is shutting down because it crashed.- Returns:
- A
CompletableFuturefor when all players have finished being added to their target world.
-
getGameplayConfig
- Returns:
- the
GameplayConfiginstance of this world.
-
getFeatures
- Returns:
- an unmodifiable view of the client features map for this world.
-
isFeatureEnabled
Checks if a client feature is enabled for this world.- Parameters:
feature- the feature to check.- Returns:
- true if the feature is enabled, false otherwise.
-
registerFeature
Registers (enables or disables) a client feature for this world. This will broadcast the updated features to all players in this world.- Parameters:
feature- the feature to register.enabled- whether the feature is enabled.
-
broadcastFeatures
public void broadcastFeatures()Broadcasts the current feature state to all players in this world. -
getSavePath
- Returns:
- the save path of this world.
-
updateEntitySeed
-
markGCHasRun
public void markGCHasRun()Called to mark that a garbage collection has run in this world. -
consumeGCHasRun
public boolean consumeGCHasRun()Consume whether a garbage collection has run since the last time this method was called.- Returns:
trueif a garbage collection has run since the last time this method was called,falseotherwise.
-
isSavingLocked
public boolean isSavingLocked()Whether saving of this world is prevented due to another process wanting to access the files manually. e.g. backups -
lockSaving
public void lockSaving()Increments the saving lock counter, preventing any saving systems from writing to disk. -
unlockSaving
public void unlockSaving()Decrements the saving lock counter, allowing saving to resume once all locks are released. -
hashCode
-
equals
-
toString
-